我是GAE的新手初學者。我現在在GAE上主持一個網站。 我想將http://abc.com/about.html的URL更改爲http://abc.com/about/ 我該怎麼辦?謝謝。如何在GAE中設置動態網址?
這裏是我的main.py:
import webapp2
from google.appengine.ext.webapp2 import template
from google.appengine.ext.webapp2 import util
import os
class MainHandler(webapp2.RequestHandler):
def get(self):
template_values = {}
path = os.path.join(os.path.dirname(__file__), 'index.html')
self.response.out.write(template.render(path, template_values))
class About(webapp2.RequestHandler):
def get(self):
self.response.our.write(template.render('about.html',None))
def main()
application = webapp2.WSGIApplication([(
'.', MainHandler),
('about', About),
])
util.run_wsgi_app(application)
app = webapp2.WSGIApplication([('/', MainHandler)],
debug=True)
這裏是我的app.yaml:
application: nienyiho-test
version: 1
runtime: python27
api_version: 1
threadsafe: yes
handlers:
- url: /favicon\.ico
static_files: favicon.ico
upload: favicon\.ico
- url: .*
script: main.app
- url: /about
static_files: about.html
upload: about.html
libraries:
- name: webapp2
version: "2.5.1"
爲什麼你不顯示使用你的'app.yaml'文件和實現你的web處理程序的代碼。 –
嗨,亞當,我已經上傳了我的main.py。謝謝。 – lavitanien