Upgrading to Python 2.7 Google App Engine 500 server error
I just started using Google App Engine and I am very new to Python. I may
have made a stupid mistake or a fatal error, I don't know, but I realized
that the basic "template" I downloaded from a website was old and used
Python 2.5.
So, I decided to update to Python 2.7 (after recieving a warning in the
site's dashboard).
I have no idea how to do this, but I blindly followed some instructions on
how to update but I'm not sure what I did wrong.
I know that I downloaded Python 2.7 (as the download path is
C:/Python27/), so there shouldn't be a problem there. Can anybody tell
what I'm doing wrong?
Original app.yaml:
application: this-site-2
version: 1
runtime: python
threadsafe: true
api_version: 1
handlers:
- url: /robots.txt
static_files: static/robots.txt
upload: static/robots.txt
- url: /css
static_dir: static/css
- url: /img
static_dir: static/img
- url: /js
static_dir: static/js
- url: /.*
script: main.py
Original main.py:
import os
from google.appengine.ext import webapp
from google.appengine.ext.webapp import util
from google.appengine.ext.webapp import template
class MainHandler(webapp.RequestHandler):
def get (self, q):
if q is None:
q = 'index.html'
path = os.path.join (os.path.dirname (__file__), q)
self.response.headers ['Content-Type'] = 'text/html'
self.response.out.write (template.render (path, {}))
def main ():
application = webapp.WSGIApplication ([('/(.*html)?', MainHandler)],
debug=True)
util.run_wsgi_app (application)
if __name__ == '__main__':
main ()
New app.yaml:
application: this-site-2
version: 1
runtime: python27
threadsafe: true
api_version: 1
libraries:
- name: jinja2
version: latest
handlers:
- url: /robots.txt
static_files: static/robots.txt
upload: static/robots.txt
- url: /css
static_dir: static/css
- url: /img
static_dir: static/img
- url: /js
static_dir: static/js
- url: /.*
script: main.app
New main.py:
import webapp2
import jinja2
import os
from google.appengine.api import mail
jinja_environment =
jinja2.Environment(autoescape=True,loader=jinja2.FileSystemLoader(os.path.join(os.path.dirname(__file__),
'templates')))
class MainHandler(webapp.RequestHandler):
def get (self, q):
if q is None:
q = 'index.html'
path = os.path.join (os.path.dirname (__file__), q)
self.response.headers ['Content-Type'] = 'text/html'
self.response.out.write (template.render (path, {}))
class contact(webapp2.RequestHandler):
template = jinja_environment.get_template('contact.html')
def get(self):
self.response.out.write(self.template.render())
def post(self):
# takes input from user
userMail=self.request.get("email")
subject=self.request.get("name")
userMessage=self.request.get("message")
message=mail.EmailMessage(sender="decotton@gmail.com",subject="New
message from website")
# not tested
if not mail.is_email_valid(userMail):
self.response.out.write("Wrong email! Check again!")
message.to=userMail
message.body="""Thank you!
You have entered following information:
Your mail: %s
Subject: %s
Name: %s
Message: %s""" %(userMail,subject,name,userMessage)
message.send()
self.response.out.write("Message sent!")
app = webapp2.WSGIApplication([('/contact',contact)], debug=True)
So, I deployed the website and everything seemed nice and fine during the
deployment, and the console said it worked and exited with code 0:
2013-09-11 20:53:36 Running command: "['C:\\Python27\\pythonw.exe', '-u',
'C:\\Program Files (x86)\\Google\\google_appengine\\appcfg.py',
'--no_cookies', u'--email=*******@gmail.com', '--passin', 'update',
u'C:\\Users\\******\\Desktop\\Web Design\\David Cotton Woodworks']"
08:53 PM Host: appengine.google.com
08:53 PM Application: this-site-2; version: 1
08:53 PM
Starting update of app: this-site-2, version: 1
08:53 PM Getting current resource limits.
Password for *******@gmail.com: 08:53 PM Scanning files on local disk.
08:53 PM Cloning 172 static files.
08:53 PM Cloning 16 application files.
08:53 PM Uploading 1 files and blobs.
08:53 PM Uploaded 1 files and blobs
08:53 PM Compilation starting.
08:53 PM Compilation completed.
08:53 PM Starting deployment.
08:53 PM Checking if deployment succeeded.
08:53 PM Deployment successful.
08:53 PM Checking if updated app version is serving.
08:53 PM Completed update of app: this-site-2, version: 1
08:53 PM Uploading index definitions.
2013-09-11 20:53:59 (Process exited with code 0)
You can close this window now.
But, I try to visit the site and I get this:
Error: Server Error
The server encountered an error and could not complete your request.
If the problem persists, please report your problem and mention this error
message and the query that caused it.
No comments:
Post a Comment