Reputation: 939
For example, I have the following files in local folders:
user/website/abc/photos/2012/august.html user/website/abc/photos/2012/september.html
I want to upload these two html pages to GAE and setup the URL as: (Let's assume that www.abc.com is the domain that I own.)
http://www.abc.com/photos/august/ http://www.abc.com/photos/september/
How can I do this?
The following is my code currently. I haven't found a way to solve it.
main.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)
app.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"
Upvotes: 0
Views: 415
Reputation: 31928
You can do something like this:
class PhotosHandler(webapp2.RequestHandler):
def get(self, year, month):
path = os.path.join(os.path.dirname(__file__), 'photos', year, '%s.html' % month)
self.response.out.write(template.render(path, None))
// delete the main
app = webapp2.WSGIApplication([('/', MainHandler),
('/photos/(.*)/(.*)', PhotosHandler)
],
debug=True)
#app.yaml
handlers:
- url: /photos/.*
script: main.app
Upvotes: 1