1
My project is running perfectly on the localhost but when I deploy and access it gives the following error: Here is my code:
import os
import jinja2
import webapp2
import json
from google.appengine.ext import db
from google.appengine.api import users
template_dir = os.path.join(os.path.dirname(__file__), 'templates')
jinja_env = jinja2.Environment(loader = jinja2.FileSystemLoader(template_dir), autoescape = True)
class Times(db.Model):
time = db.StringProperty(multiline = False)
class Handler(webapp2.RequestHandler):
def write(self, *a, **kw):
self.response.out.write(*a, **kw)
def render_str(self, template, **params):
t = jinja_env.get_template(template)
return t.render(params)
def render(self, template, **kw):
self.write(self.render_str(template, **kw))
class MainPage(Handler):
def get(self):
alltimes = db.GqlQuery("SELECT * FROM Times")
self.render("index.html", alltimes = alltimes)
def post(self):
newtime = Times()
newtime.time = self.request.get('time')
newtime.put()
self.response.out.write(self.request.get('time'))
app = webapp2.WSGIApplication([
('/', MainPage),('/times', MainPage)
], debug=True)
The hierarchy of folders:
Aquivo YAML:
application: ichronoapp
version: 1
runtime: python27
api_version: 1
threadsafe: yes
handlers:
- url: /(.*\.js)
mime_type: text/javascript
static_files: static/\1
upload: static/(.*\.js)
- url: /favicon\.ico
mime_type: image/png
static_files: static/favicon.ico
upload: static/favicon.ico
- url: /(.*\.css)
mime_type: text/css
static_files: static/\1
upload: static/(.*\.css)
- url: /(.*\.html)
mime_type: text/html
static_files: templates/\1
upload: templates/(.*\.html)
- url: /(.*\.ico)
mime_type: image/x-icon
static_files: static/\1
upload: static/(.*\.ico)
expiration: "7d"
- url: /(.*\.json)
mime_type: application/json
static_files: static/\1
upload: static/(.*\.json)
expiration: "1s"
- url: /(.*\.otf)
mime_type: font/opentype
static_files: static/\1
upload: static/(.*\.otf)
- url: /(.*\.(ttf|ttc))
mime_type: application/x-font-ttf
static_files: static/\1
upload: static/(.*\.(ttf|ttc))
- url: /(.*\.txt)
mime_type: text/plain
static_files: static/\1
upload: static/(.*\.txt)
- url: /(.*\.webp)
mime_type: image/webp
static_files: static/\1
upload: static/(.*\.webp)
- url: /(.*\.woff)
mime_type: application/x-font-woff
static_files: static/\1
upload: static/(.*\.woff)
- url: /(.*\.woff2)
mime_type: application/x-font-woff
static_files: static/\1
upload: static/(.*\.woff2)
- url: /(.*\.xml)
mime_type: application/xml
static_files: static/\1
upload: static/(.*\.xml)
expiration: "1h"
# image files
- url: /(.*\.(bmp|gif|jpeg|jpg|png))
static_files: static/\1
upload: static/(.*\.(bmp|gif|jpeg|jpg|png))
# audio files
- url: /(.*\.(mid|midi|mp3|wav))
static_files: static/\1
upload: static/(.*\.(mid|midi|mp3|wav))
# windows files
- url: /(.*\.(doc|exe|ppt|rtf|xls))
static_files: static/\1
upload: static/(.*\.(doc|exe|ppt|rtf|xls))
# compressed files
- url: /(.*\.(bz2|gz|rar|tar|tgz|zip))
static_files: static/\1
upload: static/(.*\.(bz2|gz|rar|tar|tgz|zip))
- url: /.*
script: main.app
libraries:
- name: jinja2
version: latest
- name: webapp2
version: latest
I believe the solution to your problem is this: http://stackoverflow.com/a/11015407/1840019. In the future avoid posting logs in the form of prints.
– rodorgas