4

I have just started shared hosting on godaddy starter pack. I followed the instructions here to set up CGI with FLASK: http://flask.pocoo.org/docs/deploying/cgi/

But when i run the cgi.py then i get this error:

Traceback (most recent call last):
  File "/home/railwayapi/python/lib/python3.4/wsgiref/handlers.py", line 137, in run
    self.result = application(self.environ, self.start_response)
  File "/home/railwayapi/flasker/lib/python3.4/site-packages/flask/app.py", line 1836, in __call__
    return self.wsgi_app(environ, start_response)
  File "/home/railwayapi/flasker/lib/python3.4/site-packages/flask/app.py", line 1812, in wsgi_app
    ctx = self.request_context(environ)
  File "/home/railwayapi/flasker/lib/python3.4/site-packages/flask/app.py", line 1773, in request_context
    return RequestContext(self, environ)
  File "/home/railwayapi/flasker/lib/python3.4/site-packages/flask/ctx.py", line 224, in __init__
    self.url_adapter = app.create_url_adapter(self.request)
  File "/home/railwayapi/flasker/lib/python3.4/site-packages/flask/app.py", line 1602, in create_url_adapter
    server_name=self.config['SERVER_NAME'])
  File "/home/railwayapi/flasker/lib/python3.4/site-packages/werkzeug/routing.py", line 1165, in bind_to_environ
    server_name = environ['SERVER_NAME']
KeyError: 'SERVER_NAME'
Status: 500 Internal Server Error
Content-Type: text/plain
Content-Length: 59

This is the main part: server_name = environ['SERVER_NAME']

KeyError: 'SERVER_NAME'

Why?

svetaketu
  • 269
  • 1
  • 10

1 Answers1

0

The .cgi file has to remain as it is mentioned in the Flask documentation.

Maybe you can refer to this -

https://medium.com/@mohdejazsiddiqui/deploy-flask-app-in-apache-shared-hosting-5b3c82c8fd5e

Ejaz
  • 1,504
  • 3
  • 25
  • 51
  • Did this solve your issue when setting it up? I am trying to set up a basic flask app on a shared server (where I use the .htaccess instead of the cgi-bin) and have set it up by the medium post you linked, but am still getting the error described in the problem when I try to run the `.cgi` file – user760900 Sep 21 '20 at 21:25
  • yes it worked for me. you may recheck all the setup mentioned in the post. – Ejaz Sep 22 '20 at 02:15