希望使用 Python 从特定网站获取数据以上传到 Google App Engine。这个想法是创建一个数据库数据来存储服务器上的信息,以便在 Web 应用程序中检索和显示。
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
from google.appengine.ext import db
import os
import datetime
from google.appengine.ext.webapp import template
# A class which creates all the pokemon on the server
class Pokemondata(db.Model):
number = db.IntegerProperty()
pokemonname = db.StringProperty()
description = db.StringProperty()
newpoke = Pokemondata(number="001",pokemonname="Balbasuar",description="The grass pokemon")
newpoke = Pokemondata(number="002",pokemonname="Ivysaur",description="The seed pokemon")
newpoke = Pokemondata(number="003",pokemonname="Venasaur",description="Another grass pokemon")
newpoke.put()
# A class to put new pokemon in to the server ?
class ApplyHandler(webapp.RequestHandler):
def post(self):
self.session = Session()
pnumber = self.request.get('number')
pname = self.request.get('pokemonname')
pdescription = self.request.get('description')
newpoke = Pokemondata(number=pnumber,pokemonname=pname,description=pdescription)
newpoke.put()
self.session['pokemon'] = pname
doRender(self,"board.htm",{})
# Construct a google table for this data
# to display
class JSONInterface(webapp.RequestHandler):
def get(self):
que = db.Query(Pokemondata)
listing = que.fetch(limit = 12)
doRender(self,'http://pokedexapp.appspot.com/?user=cater54321@gmail.com#input',
{'listing':listing})
application = webapp.WSGIApplication([('/(.*html)?', ApplyHandler),
('/json', JSONInterface)], debug=True)
def main():
run_wsgi_app(application)
if __name__ == "__main__":
main()
当我部署应用程序进行测试时,我收到服务器错误。谁能告诉我这是否是朝着正确方向迈出的一步以及需要修改什么?
当前的yaml文件是
应用程序:pokedexapp 版本:1 运行时:python api_version:1
处理程序:- url:/.* 脚本:main.py