简体   繁体   中英

500 server error doesn't serve index.html

I'm using python 2.7 to deploy a very simple website to Google cloud and I'm getting the 500 Server Error error message "The server encountered an error and could not complete your request. Please try again in 30 seconds." I'm new to Python and I suspect that the issue is with my app.yaml and/or my main.py. Here they are:

app.yaml:

runtime: python27
api_version: 1
threadsafe: true

handlers:

- url: /
  script: home.app

- url: /index\.html
  script: home.app

- url: /(.*\.(gif|png|jpg|ico|js|css|zip|xlsm|html))
  static_files: \1
  upload: (.*\.(gif|png|jpg|ico|js|css|zip|xlsm|html))

- url: .*
  script: myapp.app

vm_health_check:
  enable_health_check: False

main.py:

import webapp2

class MainPage(webapp2.RequestHandler):
    def get(self):
        self.render('index.html')

app = webapp2.WSGIApplication([('/index.html', MainPage)])

The server should serve the index.html file, but it is not. How can I modify either the app.yaml or the main.py file(s) to get the server to serve the index.html file when the page loads? Is there something else I should do as well?

Thanks,

William

I got it working. I didn't use main.py and I just used the app.yaml file. Here is the new version of app.yaml:

runtime: python27
api_version: 1
threadsafe: true

handlers:
- url: /
  static_files: index.html
  upload: index.html


- url: /(.*\.(gif|png|jpg|ico|js|css|zip|xlsm|html))
  static_files: \1
  upload: (.*\.(gif|png|jpg|ico|js|css|zip|xlsm|html))

That was it! No fuss, no muss.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM