pythonflaskgoogle-cloud-platformgcloud

Flask api on gcloud's URL keeps on loading


I thought that the error was in the code first but, it was in the deployment. So, i deployed my flask api on gcloud after researching a lot. But as I run the URL of my app. It keeps on loading and loading.

i want my api to work properly


Solution

  • You have a typographical error. You named your file requirments.txt instead of requirements.txt i.e. you're missing letter 'e' after letter 'r'. Because of this, your modules/packages aren't installed which means your code won't work (you should see the errors if you check the logs).

    Extra: Next time, include the specific solution/part of gcloud you're using in your question or the tag(in this case, you're using Google App Engine Standard Flex)

    Updates

    1. You have app:app in your GUNICORN_CMD_ARGS env variable but your app object is in a main.py file and not an app.py file (you have the correct thing in your entrypoint variable.

    2. Since you have an entrypoint, I don't believe you need the GUNICORN_CMD_ARGS. Try the following & see if it resolves your issue - remove GUNICORN_CMD_ARGSand update your entrypoint to

      gunicorn -b :$PORT --threads=8 --timeout=7 main:app

      According to gunicorn documentation, a default value of 1 is used for workers if you don't specify it

    3. You should also note that using GAE Flex over GAE standard is more expensive because Flex needs at least 1 instance to always be up whereas Standard can go down to 0 when there's no traffic which in turn means you're paying less. The downside is that it takes sometime to start up an instance when it receives new traffic