Flask Gunicorn app can't get __name__ to equal '__main__'

后端 未结 1 995
南旧
南旧 2020-11-28 16:15

I have this from /home/myname/myapp/app.py:

from flask import Flask

app = Flask(__name__)

print __name__

@app.route(\'/\')
def index():
    r         


        
相关标签:
1条回答
  • 2020-11-28 16:44

    Python sets __name__ to "__main__" when the script is the entry point for the Python interpreter. Since Gunicorn imports the script it is running that script will not be the entry point and so will not have __name__ set to "__main__".

    0 讨论(0)
提交回复
热议问题