Google App Engine project Python works on localhost but gives server error

1

My project is running perfectly on localhost but when I do 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 folder hierarchy:

YAML:

application:ichronoappversion:1runtime:python27api_version:1threadsafe:yeshandlers:-url:/(.*\.js)mime_type:text/javascriptstatic_files:static/upload:static/(.*\.js)-url:/favicon\.icomime_type:image/pngstatic_files:static/favicon.icoupload:static/favicon.ico-url:/(.*\.css)mime_type:text/cssstatic_files:static/upload:static/(.*\.css)-url:/(.*\.html)mime_type:text/htmlstatic_files:templates/upload:templates/(.*\.html)-url:/(.*\.ico)mime_type:image/x-iconstatic_files:static/upload:static/(.*\.ico)expiration:"7d"

- url: /(.*\.json)
  mime_type: application/json
  static_files: static/
  upload: static/(.*\.json)
  expiration: "1s"

- url: /(.*\.otf)
  mime_type: font/opentype
  static_files: static/
  upload: static/(.*\.otf)

- url: /(.*\.(ttf|ttc))
  mime_type: application/x-font-ttf
  static_files: static/
  upload: static/(.*\.(ttf|ttc))

- url: /(.*\.txt)
  mime_type: text/plain
  static_files: static/
  upload: static/(.*\.txt)

- url: /(.*\.webp)
  mime_type: image/webp
  static_files: static/
  upload: static/(.*\.webp)

- url: /(.*\.woff)
  mime_type: application/x-font-woff
  static_files: static/
  upload: static/(.*\.woff)

- url: /(.*\.woff2)
  mime_type: application/x-font-woff
  static_files: static/
  upload: static/(.*\.woff2)

- url: /(.*\.xml)
  mime_type: application/xml
  static_files: static/
  upload: static/(.*\.xml)
  expiration: "1h"

# image files
- url: /(.*\.(bmp|gif|jpeg|jpg|png))
  static_files: static/
  upload: static/(.*\.(bmp|gif|jpeg|jpg|png))

# audio files
- url: /(.*\.(mid|midi|mp3|wav))
  static_files: static/
  upload: static/(.*\.(mid|midi|mp3|wav))

# windows files
- url: /(.*\.(doc|exe|ppt|rtf|xls))
  static_files: static/
  upload: static/(.*\.(doc|exe|ppt|rtf|xls))

# compressed files
- url: /(.*\.(bz2|gz|rar|tar|tgz|zip))
  static_files: static/
  upload: static/(.*\.(bz2|gz|rar|tar|tgz|zip))

- url: /.*
  script: main.app
libraries:

- name: jinja2
  version: latest

- name: webapp2
  version: latest
    
asked by anonymous 23.12.2016 / 20:37

1 answer

0

What I know that external libraries need to be inserted into the project, a lib folder for example, and the folder referenced in the appengine_config.py file.

Example:

from google.appengine.ext import vendor

# Add any libraries install in the "lib" folder.
vendor.add('lib')

See if that's the case.

    
17.11.2017 / 18:24