У приложения есть структура
Код: Выделить всё
myApp
├── app
│ ├── about
│ │ ├── __init__.py
│ │ └── routes.py
│ ├── extensions.py
│ ├── __init__.py
│ ├── main
│ │ ├── __init__.py
│ │ └── routes.py
│ ├── models
│ │ ├── contact.py
│ ├── static
│ │ ├── myApp.css
│ │ ├── favicon-16x16.png
│ └── templates
│ ├── about
│ │ └── index.html
│ ├── base.html
│ └── index.html
├── bin
│ ├── activate
│ ├── flask
│ ├── pip
│ ├── python -> python3.12
│ ├── python3 -> python3.12
│ ├── python3.12 -> /usr/bin/python3.12
│ ├── uwsgi
│ └── wheel
├── config.py
├── myApp.db
├── myApp -> /home/janeDoe/myApp
├── myApp.ini
├── include
│ └── ...
├── lib
│ └── ...
├── lib64 -> lib
├── pyvenv.cfg
├── requirements.txt
└── wsgi.py
Код: Выделить всё
cd /home/janeDoe/myApp
flask run
Если я попытаюсь запустить с uwsgi, как показано в
Код: Выделить всё
cd /home/janeDoe/myApp
uwsgi --socket 0.0.0.0:5000 --protocol=http -w wsgi:app
Код: Выделить всё
wsgi.py:
from myApp import app
app.run()
Код: Выделить всё
app/__init__.py:
from flask import Flask
from config import Config
from app.extensions import db
from flask_favicon import FlaskFavicon
def create_app(config_class=Config):
app = Flask(__name__)
app.config.from_object(config_class)
# Initialize Flask extensions here
db.init_app(app)
# Register blueprints here
from app.main import bp as main_bp
app.register_blueprint(main_bp)
from app.about import bp as about_bp
app.register_blueprint(about_bp, url_prefix="/about")
flaskFavicon = FlaskFavicon()
flaskFavicon.init_app(app)
flaskFavicon.register_favicon("app/static/favicon-16x16.png", "default")
@app.route("/test/")
def test_page():
return "Testing the Flask Application Factory Pattern"
return app
Код: Выделить всё
...
mapped 72920 bytes (71 KB) for 1 cores
*** Operational MODE: single process ***
Traceback (most recent call last):
File "/home/JaneDoe/myApp/wsgi.py", line 5, in
app.run()
^^^^^^^
AttributeError: module 'myApp.app' has no attribute 'run'
unable to load app 0 (mountpoint='') (callable not found or import error)
*** no app loaded. going in full dynamic mode ***
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI worker 1 (and the only) (pid: 1321333, cores: 1)
Подробнее здесь: https://stackoverflow.com/questions/786 ... g-to-run-a