Example: Develop Web application on Baidu App Engine using CherryPy
In the past few months, I have developed two simple applications on Baidu App Engine. Compared to Google App Engine, or Nitrous.Io, the documentation of BAE is really not good enough. The only advantage of BAE is stable - you needn't to worry about GFW - on Mainland China. I'm used to CherryPy to do simple web applications, and after some attempts, I figure out how to deploy it to BAE:
1. Create a deployment on BAE
Remember to select the type as python-web.
2. Checkout and modify code
When done, notice these files:
requirements.txt
As the documentation says, this is where we declare the library dependencies we want. So we just write:
cherrypy
app.conf
Here to let it work, modify it like this:
handlers:
- url : /*
script: index.py - expire : .jpg modify 10 years
- expire : .swf modify 10 years
- expire : .png modify 10 years
- expire : .gif modify 10 years
- expire : .JPG modify 10 years
- expire : .ico modify 10 years
The key here is that url property should be /* rather than /. And notice index.py is the entrance of your application.
index.py
Basiclly, this file will look like this:
#-*- coding:utf-8 -*-
import cherrypy
import script try:
from bae.core.wsgi import WSGIApplication
app = cherrypy.tree.mount(script.HelloWorld(environment), "/", config=script.CONFIG)
application = WSGIApplication(app)
except ImportError:
cherrypy.quickstart(script.HelloWorld(environment), config=script.CONFIG)
Here the 'script.py' is just a file I created to handle the actual logic. The key here is WSGIApplication which is offered by BAE, and we should wrap our app created by CherryPy framework with it. Using try... except structure here, we can use same code both on BAE and on local environment, which makes debugging more convenient.
3. Problem remain: Session
It seems that the session function will not work very well on BAE, I've tried different configurations but can't make it. Next time I will go into it and try to figure out the reason.
Example: Develop Web application on Baidu App Engine using CherryPy的更多相关文章
- 第一个Django项目及部署到Sina App Engine
Sina App Engine简称SAE,是个比较好的网站托管平台,目前说是全面免费,其实就是每个人分配很小的资源配额,在一定的使用范围内不用消耗云豆(SAE计费方式),对于个人学习和研究足够了,同类 ...
- 云计算平台简介(App Engine)
云计算平台简介(App Engine) 1 简介 App Engine: 应用程序引擎,是托管网络应用程序的云计算平台. 1.1 什么是云 云计算通常简称为“云”,是一种通过 Inter ...
- What technical details should a programmer of a web application consider before making the site public?
What things should a programmer implementing the technical details of a web application consider bef ...
- Google App Engine, Python2.7的UnicodeDecodeError bug
在跟Web Development,要在Google App Engine上写作业,出师不利,遇到以下bug: 2014-05-06 16:14:17 Running command: "[ ...
- 介绍Google App Engine
Google App Engine是一个网络应用托管服务(web application hosting service).所谓网络应用(By web application),我们的意思的可以通过网 ...
- Google App Engine 学习和实践
这个周末玩了玩Google App Engine,随手写点东西,算是学习笔记吧.不当之处,请多多指正. 作者:liigo,2009/04/26夜,大连 原创链接:http://blog.csdn.ne ...
- [Windows Azure] Adding Sign-On to Your Web Application Using Windows Azure AD
Adding Sign-On to Your Web Application Using Windows Azure AD 14 out of 19 rated this helpful - Rate ...
- Collabration Web Application Screenshot(English Language) Free download now!
The screenshots of english language version collabration web application which is as following: Incl ...
- Python Flask 在Sina App Engine (SAE)上安家
早就听说了Python的大名,随着的编程语言的理解加深,越发认为动态语言的威力--真大呀. 趁这段时间不忙,我也用Python写了一个应用,而且将其部署到Sina App Engine (SAE).S ...
随机推荐
- Python之路第十天,高级(2)-多线程,多进程,协程
线程 threading threading模块对象 描述 Thread 表示一个线程的执行对象 Lock 锁原语对象 RLock 可重入锁对象,使单线程可再次获得已经获得了的锁(递归锁定) Cond ...
- 在Django里查询数据库时,如何按照desc倒序返回数据?
按照entry_date从小到大查询数据,可以写成: Content.objects.order_by('entry_date') 从大到小排序: Content.objects.order_by(' ...
- More is better--hdu1856(并查集)
More is better Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 327680/102400 K (Java/Others) ...
- codeforces 519A. A and B and Chess,
A. A and B and Chess time limit per test 1 second memory limit per test 256 megabytes input standard ...
- Nginx学习之三-ngx_http_request_t结构体
ngx_http_request_s是nginx中非常重要的一个结构体,贯穿于htpp请求处理的整个过程中. 下面解释了ngx_http_request_s结构体中与HTTP框架相关的重要的成员变量. ...
- GDAL库学习笔记(1):无缝拼接Google卫星图
开工之前要先了解一下瓦片地图,瓦片地图金字塔模型是一种多分辨率层次模型,从瓦片金字塔的底层到顶层,分辨率越来越低,但表示的地理范围不变.实现原理就是,首先确定地图服务平台所要提供的缩放级别的数量N,把 ...
- Oracle EBS-SQL (OM-6):打开订单.sql
/*打开头*/ update oe_order_headers_all t set t.flow_status_code = 'BOOKED', t.open_flag = 'Y' where t.o ...
- logcat错误日志
http://www.crifan.com/android_log_to_file/ http://www.iteye.com/problems/85431 http://www.cnblogs.co ...
- Delphi 技巧改造HINT的输出方式
Delphi中使用提示是如此简单,只需将欲使用Hint的控件作如下设置: ShowHint := True; Hint := ‘提示信息’; 不必写一行代码,相当方便. 但有时我们又想自己定制提示的效 ...
- malloc用法
malloc用法三部曲:(#include<stdlib.h>下的库函数) 1.malloc eg.ps=(char*)malloc(sizeof(char)*20)的意思是,动态分配空间 ...