我有这个来自/home/myname/myapp/app.py:
from flask import Flask
app = Flask(__name__)
print __name__
@app.route('/')
def index():
return "Hello world!"
if __name__ == '__main__':
print 'in if'
app.run()
Run Code Online (Sandbox Code Playgroud)
当我跑:
$ gunicorn app:app -b 127.0.0.2:8000
Run Code Online (Sandbox Code Playgroud)
它说:
2013-03-01 11:26:56 [21907] [INFO] Starting gunicorn 0.17.2
2013-03-01 11:26:56 [21907] [INFO] Listening at: http://127.0.0.2:8000 (21907)
2013-03-01 11:26:56 [21907] [INFO] Using worker: sync
2013-03-01 11:26:56 [21912] [INFO] Booting worker with pid: 21912
app
Run Code Online (Sandbox Code Playgroud)
所以该__name__应用程序是app.不__main__喜欢我需要它来运行if语句.
我试着__init__.py在目录中放空.这是我的nginx sites-enabled default:
server …Run Code Online (Sandbox Code Playgroud)