例如,我在本地文件夹中有以下文件:
用户/网站/abc/photos/2012/august.html 用户/网站/abc/photos/2012/september.html
我想将这两个 html 页面上传到 GAE 并将 URL 设置为:(假设 www.abc.com 是我拥有的域。)
http://www.abc.com/photos/august/ http://www.abc.com/photos/september/
我怎样才能做到这一点?
以下是我目前的代码。我还没有找到解决它的方法。
主要.py:
import webapp2
from google.appengine.ext.webapp import template
from google.appengine.ext.webapp 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 August(webapp2.RequestHandler):
def get(self):
self.response.out.write(template.render('august.html',None))
class September(webapp2.RequestHandler):
def get(self):
self.response.out.write(template.render('september.html',None))
def main():
application = webapp2.WSGIApplication([
('/', MainHandler),
('august', August),
('september', September),
])
util.run_wsgi_app(application)
app = webapp2.WSGIApplication([('/', MainHandler)],
debug=True)
应用程序.yaml
application: nienyihotw
version: 1
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /august
static_files: august.html
upload: august.html
- url: /september
static_files: september.html
upload: september.html
- url: /rootfolder
static_dir: rootfolder
- url: /.*
script: main.app
libraries:
- name: webapp2
version: "2.5.1"