Google App Engine Standard and Pyramid¶
It is possible to run a Pyramid application on Google App Engine. This tutorial is written in terms of using the command line on a UNIX system. It should be possible to perform similar actions on a Windows system. This tutorial also assumes you've already installed and created a Pyramid application, and that you have a Google App Engine account.
Setup¶
First we'll need to create a few files so that App Engine can communicate with our project properly.
Create the files with content as follows.
requirements.txt
Pyramid waitress pyramid_debugtoolbar pyramid_chameleon
main.py
from pyramid.paster import get_app, setup_logging ini_path = 'production.ini' setup_logging(ini_path) application = get_app(ini_path, 'main')
appengine_config.py
from google.appengine.ext import vendor vendor.add('lib')
app.yaml
1application: application-id 2version: version 3runtime: python27 4api_version: 1 5threadsafe: false 6 7handlers: 8- url: /static 9 static_dir: pyramid_project/static 10- url: /.* 11 script: main.application
Configure this file with the following values:
Replace "application-id" with your App Engine application's ID.
Replace "version" with the version you want to deploy.
Replace "pyramid_project" in the definition for
static_dir
with the parent directory name of your static assets. If your static assets are in the root directory, you can just put "static".
For more details about
app.yaml
, see app.yaml Reference.Install dependencies.
$ pip install -t lib -r requirements.txt
Running locally¶
At this point you should have everything you need to run your Pyramid application locally using dev_appserver
. Assuming you have appengine in your $PATH
:
$ dev_appserver.py app.yaml
And voilà! You should have a perfectly-running Pyramid application via Google App Engine on your local machine.
Deploying¶
If you've successfully launched your application locally, deploy with a single command.
$ appcfg.py update app.yaml
Your Pyramid application is now live to the world! You can access it by navigating to your domain name, by "<applicationid>.appspot.com", or if you've specified a version outside of your default then it would be "<version-dot-applicationid>.appspot.com".