0

After following freecampcode's web application tutorial, creating my own Google Cloud SDK project and deploying my sample social network website using Python and Flask (which I found mostly thought this tutorial), I am getting this same error: Internal/Unknown Server Error 500, which looks like:

Error: Server Error
The server encountered an error and could not complete your request.
Please try again in 30 seconds.

Checking the logs, I get the errors:

-2020-07-06 01:51:29 default[20200705t214944]  "GET / HTTP/1.1" 500
-2020-07-06 01:51:32 default[20200705t214944]  "GET /favicon.ico HTTP/1.1" 500

Any help would be greatly appreciated. I've been stuck on this issue for a while. If you need additional information on the project, please let me know. This is my first gcloud project.

EDIT: I checked the error logs and saw the error:

ImportError: No module named main
    at LoadObject (/base/alloc/tmpfs/dynamic_runtimes/python27g/174489198b39d9fb/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py:85)
at _LoadHandler (/base/alloc/tmpfs/dynamic_runtimes/python27g/174489198b39d9fb/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py:311)
at Handle (/base/alloc/tmpfs/dynamic_runtimes/python27g/174489198b39d9fb/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py:240)

So I added the file main.py with the contents:

from app.wsgi import main as app

entrypoint: gunicorn -b :$PORT app.wsgi:main

and I still get the same internal error.

2 Answers2

1

one way is to Try with DEBUG mode off

still if it not works then try this below way with this you will get exact details why you got this error

Try this it will return exact error

@app.errorhandler(500)
  def internal_server_error(e):
    return jsonify(error=str(e)), 500
M_x
  • 782
  • 1
  • 8
  • 26
1

What I noticed is that tutorial 1 (this one) contain how-to for python2, while the 2nd tutorial (this one) is how-to build with python3.

What more python2 not supported any more, so there is no point to learn how to use it. Here it is the reference.

I suppose you have to change environment in app.yaml file. Here is reference to python3 environment. I would start with that.

What I recommend you as well is to go to Google Cloud Platform and open App Engine (direct link). On the right you have a possibility to go with tutorial called "App Engine Quickstart" or "Hello World". You can choose Python and go trough whole process of creating HelloWorld app, which by the way is Flask as well. I would try it even before the once you are trying.

I hope it will help!

vitooh
  • 4,132
  • 1
  • 5
  • 16
  • Works now - thanks so much! The main issue was that my virtual environment was restricted to python2.7 - I created a new one and the problem is fixed. I appreciate your help! – David D'Silva Jul 08 '20 at 12:08
  • please consider accepting the answer, I will appreciate! Thanks! – vitooh Jul 08 '20 at 13:04