New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
added docs for deploying as a google app engine application #39
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
--- | ||
layout: default | ||
title: Webpy + Google App Engine | ||
--- | ||
|
||
# Webpy + Google App Engine | ||
|
||
This cookbook entry explains how to run web.py as a google app engine application | ||
|
||
### Requirements | ||
|
||
* Google App Engine Python API | ||
|
||
### Resources | ||
|
||
* [Google App Engine](https://developers.google.com/appengine/downloads#Google_App_Engine_SDK_for_Python) | ||
|
||
### Notes | ||
* The mechanisms for running GAE in python2.7 and 2.5 are different, change the app.yaml accordingly | ||
* code.py is the main file of your application (2.5) | ||
* code.app is the main file that includes the global variable app (2.7) | ||
* appname is the name that you specified while creating your GAE application | ||
* runtime for 2.5 is python, 2.7 is python27 | ||
* threadsafe is only required in 2.7, read about it on the google app engine site | ||
|
||
## app.yaml for python 2.5 | ||
|
||
application: appname | ||
version: 1 | ||
runtime: python | ||
api_version: 1 | ||
|
||
handlers: | ||
- url: /.* | ||
script: code.py | ||
|
||
## app.yaml for python 2.7 | ||
|
||
application: appname | ||
version: 1 | ||
runtime: python27 | ||
api_version: 1 | ||
threadsafe: true | ||
|
||
handlers: | ||
- url: /.* | ||
script: code.app | ||
|
||
To serve static files, you must add this under handlers (where static is the name of your static dir): | ||
- url: /static | ||
static_dir: static | ||
|
||
## Hello World! | ||
|
||
This is a sample application that can be run by using dev_appserver.py (it is bundled with the SDK download): | ||
|
||
import web | ||
|
||
urls = ( | ||
"/.*", "hello", | ||
) | ||
|
||
app = web.application(urls, globals()) | ||
|
||
class hello: | ||
def GET(self): | ||
return 'Hello, world!' | ||
|
||
app = app.gaerun() | ||
|
||
Save this as code.py (or whatever you specified in app.yaml) and type: | ||
dev_appserver.py . | ||
|
||
Now visit localhost:8080 in your browser and you should see hello world! | ||
|
||
## NOTES | ||
|
||
### There is a blank page or an internal server error | ||
|
||
solution: Make sure that you are running the version of python specified in the app.yaml file | ||
|
||
### dev_appserver.py is not found | ||
|
||
solution: Make sure that it is in your path |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean the object in the main file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea, my bad.