Reputation: 157
I am looking to discover the best possible practice for building up a file tree inside a GAE/python.
It seems rather efficient to keep everything in one file and route everything there via WSGI.
Though for a complex and multifaceted site it makes sense to have distinct files serving different purposes.
I ran into some weird complications when I had many urls listed in the app.yaml
handlers:
- url: /favicon\.ico
static_files: favicon.ico
upload: favicon\.ico
- url: /unit3.*
script: unit3.app
- url: /birthday.*
script: birthday.app
- url: /signup.*
script: signup.app
- url: /rot13.*
script: rot13.app
- url: /welcome.*
script: signup.app
- url: .*
script: main.app
libraries:
- name: webapp2
version: "2.5.1"
- name: jinja2
version: latest
and then having to duplicate those paths in separate .py files
app = webapp2.WSGIApplication([('/signup',SignUpHandler),
('/welcome',WelcomeHandler),
('/signup/.*', NotFoundPageHandler)]
,debug=True)
Is it weird that I think having to detail the routing of the url twice or more is cumbersome? Is there a way to have distinct files (html, css, py, js) and then have the app.yaml connect all the dots with the routing?
Upvotes: 2
Views: 2127
Reputation: 4228
Best way to go is use webapp2 framework, routing is very simple there. You can then just define urls.py and add routes there. http://webapp-improved.appspot.com/ Routing in webapp. http://webapp-improved.appspot.com/api/webapp2.html#uri-routing
Here is boilerplate code to get you started. https://github.com/coto/gae-boilerplate
Upvotes: 2