伟
你必须创建一个url模式,就像你在myapp上获得请求一样,你将解析剩余的url并显示消息.
例如
文件helloworld / app.yaml
application: helloworld
version: 1
runtime: python
api_version: 1
handlers:
- url: /.*
script: helloworld.py
文件helloworld / helloworld.py
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
class MainPage(webapp.RequestHandler):
def get(self, url=None):
self.response.headers['Content-Type'] = 'text/plain'
self.response.out.write('Happy New Year '+str(url))
#application = webapp.WSGIApplication(
# [('/', MainPage)],
# debug=True)
application = webapp.WSGIApplication([
(r'/myapp/(?P\d{4})/$', MainPage)
],
debug=True)
def main():
run_wsgi_app(application)
if __name__ == "__main__":
main()
因此,这将处理您在/ myapp / year / so的所有请求,您必须在/ myapp /之后获取值并显示年份.
注意:请长期自己做,这样你就会知道它将如何运作:).