Reputation: 41
Flask app it's ok,but when I use Gunicorn command:
gunicorn -w 4 -b 127.0.0.1:8004 app:app
or
gunicorn -w 4 -b 127.0.0.1:8004 route:app
it seems ImportError: No module named 'app'
my structure
app
│ config.py
│ data.db
│ forms.py
│ models.py
│ mulu.txt
│ route.py
│ __init__.py
│ templates
| static
app is defined in init.py
from flask import Flask
app = Flask(__name__)
route.py
from app import app
@app.route('/')
def hello_world():
return 'hello world'
if __name__ == '__main__':
app.run()
Why?Thanks!
Upvotes: 1
Views: 1077
Reputation: 2115
Your app instance is defined in __init__.py
, so you should do
gunicorn -w 4 -b 127.0.0.1:8004 __init__:app
Upvotes: 3