Configure app.yaml in GAE to allow selection of scripts through URL
I have created an app in Google App Engine and it's working pretty well in a conventional browser. The main script is called example.py (because I have been hacking off an example and I never changed it). It calls a html file and passes in variables as you would expect.
Now I want to develop a new version that's more suitable for mobile devices. To do this, I wrote a new python script called example_mobile.py. It's similar to example.py except that it calls a different html file with a different stylesheet. Inelegant I know but I thought it would be easy to implement through the app.yaml file.
Here is my app.yaml file:
application: (my application id string)
version: 1
runtime: python
api_version: 1
handlers:
- url: /remote_api
script: $PYTHON_LIB/google/appengine/ext/remote_api/handler.py
login: admin
- url: /stylesheets
static_dir: stylesheets
- url: /javascript
static_dir: javascript
- url: /images
static_dir: images
开发者_开发技巧
- url: /mobile/.*
script: example_mobile.py
- url: /.*
script: example.py
www.(my domain name).com pulls up the output from example.py no problem. I was hoping that www.(my domain name).com/mobile would pull up the output from example_mobile.py but it didn't work. Also tried www.mobile.(my domain name).com but no luck. Tried leaving off the /.* at the end of /mobile but that didn't help either. I switched example_mobile.py and example.py to check that it wasn't the python and I got the expected result so there's definitely something wrong with how I'm formatting and using the app.yaml file. Can't seem to find a similar use case in the GAE docs so any help would be much appreciated.
Thanks,
Dessie
To trigger the /mobile/.*
route you should visit www.(my domain name).com/mobile/
One simple suggestion is to have a single example.py
matched by /.*
leaving the routing part to the WSGIApplication class.
application = webapp.WSGIApplication(
[('/mobile', example.MobileHandler),
( '/', example.MainHandler)],
debug=True)
One rule of thumb here is that on app.yaml
you should have different routes for different applications or different components.
Is mobile
a different application/components or just the same application with a different theme and some lighter features?
精彩评论