

[web.py] Web Application on Both Google App Engine and Apache
source link: http://siongui.github.io/2015/03/04/webpy-gae-apache/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

This post shows a web.py application template which runs on both Apache with mod_wsgi and Google App Engine Python.
"Hello World" web.py application
mainweb.py | repository | view raw
#!/usr/bin/env python # -*- coding:utf-8 -*- import web urls = ( r"/", "MainPage" ) class MainPage: def GET(self): return "Hello World" app = web.application(urls, globals()) try: from google.appengine.ext import ndb # runs on Google App Engine app = app.gaerun() except ImportError: application = app.wsgifunc() if __name__ == '__main__': app.run()
web.py is not included in the third-party libraries in GAE Python 2.7. To use web.py on GAE, please download web.py from Github. Put the web directory in web.py repo and this "Hello World" application in the same directory.
Sample GAE Python config
app.yaml | repository | view raw
application: webpy-gae version: 1 runtime: python27 api_version: 1 threadsafe: true handlers: - url: /.* script: mainweb.app
Sample Apache config
apache.conf | repository | view raw
<VirtualHost *:80> ServerName {{ domain_name }} ServerAdmin {{ email }} ErrorLog {{ SOME_DIR }}/logs/error_log CustomLog {{ SOME_DIR }}/logs/access_log combined Alias /favicon.ico {{ REPO_DIR }}/favicon.ico Alias /robots.txt {{ REPO_DIR }}/robots.txt WSGIScriptAlias / {{ REPO_DIR }}/mainweb.py AddType text/html .py </VirtualHost>
Development
Makefile | repository | view raw
# path of Google App Engine Python SDK GAE_PY_SDK=../../../../../google_appengine all: local devserver: $(GAE_PY_SDK)/dev_appserver.py . local: python mainweb.py
Modify the path of GAE_PY_SDK in Makefile to your path of GAE Python SDK.
Test run the web.py application locally:
# open your terminal and run $ make local # OR $ make # open browser with URL: http://localhost:8080/
Test run the web.py application on local GAE Python environment:
# open your terminal and run $ make devserver # open browser with URL: http://localhost:8080/
Tested on: Ubuntu Linux 14.10, Google App Engine Python SDK 1.9.18
References:
[1]web.py
[2]Webpy + Apache with mod_wsgi on Ubuntu (web.py)
Recommend
-
7
Secrets in Google App Engine Google App Engine makes it easy to deploy NodeJS applications. The GAE Standard Environment and SDK support NodeJS out of the box. Th...
-
12
ActionScript 3 API Service on Google App Engine Wednesday, September 3, 2008 I have just uploaded a new ActionScript 3 reference / online documentation API to Google App En...
-
6
Sending mail functionality for Google App Engine Reading Time: < 1 minuteWhen we search...
-
8
基于Google App Engine 的Adsense投放监控系统_我要去桂林-田春峰-CSDN博客 基于Google App Engine 的Adsense投放监控系统 ...
-
11
Posted by Wesley Chun, Developer Advocate, Google Cloud Next generation service Since its
-
7
Shortcomings of Google App Engine As many of you know, I have been a huge fan of Google App Engine. I love the vision and truly believe its the first real platform-as-a-service...
-
4
Is Google App Engine Ready for Prime Time? I recently took the time to build a web application on Google App Engine and wanted to share my thoughts on the experience and the pr...
-
7
Reading Application Settings in Google App Engine with Java advertisements This question already has an answer here: GWT: Ca...
-
7
Does the Google application engine use python 2.7.0 or 2.7.1? advertisements What python version does app engine use? Thi...
-
7
Google App Engine Datastore Example : Dictionary Application Updated: April 07, 2015...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK