Migrating from Python 2.5 to 2.7

40 views
Skip to first unread message

White Light Band

unread,
May 31, 2017, 9:16:26 AM5/31/17
to Google App Engine
Hi, I'm new here and to describe myself as a Python Novice would be overstating my abilities but would really like some help if possible. My website was loading using Python 2.5 but I can't work out the code to use for 2.7. I found this helpful main.py example: but I need to load my HTML (all nicely stored in a folder on my PC) rather than just a simple message per this. Can anyone help? Thanks.
import webapp2

class MainPage(webapp2.RequestHandler):
 
def get(self):
   
self.response.headers['Content-Type'] = 'text/plain'
   
self.response.out.write('Hello, WebApp World!')

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

""" Old code:
def main():
  run_wsgi_app(app)

if __name__ == '__main__':
  main()
"""

Yannick (Cloud Platform Support)

unread,
May 31, 2017, 4:25:27 PM5/31/17
to Google App Engine

 Hey there and welcome. Note that this forum is intended for general discussion on App Engine and that the best way to get answers to your specific technical questions is to post them to Stack Overflow using appropriate tags from the list of tags monitored by our community technical team. Should you post there, be sure to detail what you’re trying to accomplish. Feel free to post a link to your question here to help direct answers to the right place.

 

The code sample you’re using lets you generate responses to GET requests programmatically but it might not scale well if your goal is just to create a simple website that serves static html content; If that’s your intent, you should check out this guide on hosting a static website. If you want to build a dynamic Python web application, this tutorial on creating a guestbook application is a good place to start.


White Light Band

unread,
Jun 1, 2017, 6:46:13 AM6/1/17
to Google App Engine
Thanks Yannick - I'll do that. Much appreciated.
Reply all
Reply to author
Forward
0 new messages