I am new to GAE and I am creating an application with the webapp framework. I was wondering when do you set handlers in your app.yaml and when you define them in your WSGI?
At first I thought you only have one main.py main file running the WSGIApplication but I notice if you want to use the GAE authorization you define that in the handlers. So that means you run multiple WSGIApplications?
I was reading the documents on "Requiring Login or Administrator Status" and it seems they have different applications for different roles.
Maybe something like this?
-- general.py - login:
-- user.py - login: required
-- admin.py: - login: admin
But maybe it's bad to have your WSGI urls spread all over the place?
If I remember correctly if you run django on GAE you point to one py file and let the framework handle everything?
I don't want to use Django yet so was wonder if anybody had some pointers/best practices on how to do url/hanlders with webapp?
The handlers element is a required element in the app. yaml configuration file. The element provides a list of URL patterns and descriptions of how they should be handled. App Engine can handle URLs by executing application code, or by serving static files uploaded with the code, such as images, CSS, or JavaScript.
yaml allows you to override routing rules.
The only way you can delete the default version of your App Engine app is by deleting your project. However, you can stop the default version in the GCP Console. This action shuts down all instances associated with the version. You can restart these instances later if needed.
The standard environment can scale from zero instances up to thousands very quickly. In contrast, the flexible environment must have at least one instance running for each active version and can take longer to scale up in response to traffic. Standard environment uses a custom-designed autoscaling algorithm.
Either method of URL-routing is acceptable.
app.yaml-based URL routing
If you can easily structure your app to use app.yaml routing (and authorization), then it's worth trying: it'll be less code you'll have to debug, test, and maintain.
Here's an example (from Google) with multiple entry points: http://google-app-engine-samples.googlecode.com/svn/trunk/gdata_feedfetcher/
Performance should be superior with app.yaml authorization: Your Python script won't need to be run to determine if a user is an admin of the site.
one URL-mapping table
If your app needs something beyond basic URL-routing and authorization then you may find yourself having a comparatively sparse app.yaml and using a larger URL-mapping table.
For example, you want to display a page to all users, but additionally want a "login" link to show up for an admin. This code (for a simple blog) uses this structure.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With