I am following the instructions here to deploy an app in Google App Engine. Everything works correctly.
Nevertheless, Google, by default, looks for the main folder (where app = Flask(__name__)
is defined) in main.py
. How could I redefine this? I would like to define this main folder as app.py
.
Rename main.py
to app.py
Add entrypoint: gunicorn -b :$PORT app:app
to your app.yaml
file. This is where you are telling Google to find the app
object in a file called app
Add gunicorn
to your requirements.txt
file
Notes:
i. Because you're changing from main.py
to app.py
, you need to specify an entrypoint. GAE documentation says
If your app meets the following requirements, App Engine will start your app with the gunicorn web server if you don't specify the entrypoint field:
The root of your app directory contains a main.py file with a WSGI-compatible object called app.
Your app does not contain Pipfile or Pipfile.lock files.
ii. If you add an entrypoint, then you need to include gunicorn
in your requirements.txt file
iii. I just tested the above configuration (the answer I gave) on a dev environment (Python 3.9 environment on Macbook using dev_appserver.py) and it works
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.