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 ...
随机推荐
- asp.net实现伪静态遇到的问题
之前在一次项目(asp.net网站)中要用到伪静态技术,实现的思路大致是这样的: 在全局配置文件Global.asax(普通的类可以通过实现IHttpModule来完成)中的Application_B ...
- HTML5 canvas 在线画笔绘图工具(四)
HTML5画图命令 图形的绘制是由TDrawHandler与TCommand 协同工作完成. TDrawHandler需要完成以下工作 1.聚集类用于管理绘图的命令 TCommand 2.管理鼠标事件 ...
- Transition 所支持的css属性
transition-property是用来指定当元素其中一个属性改变时执行transition效果: 所支持的属性类型如下: color: 通过红.绿.蓝和透明度组件变换(每个数值处理)如:back ...
- js分页代码
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xh ...
- windows 激活远程桌面服务
- python cmd模块练习
# encoding=utf-8 import cmd import sys # cmd模块练习 class Client(cmd.Cmd): ''' 1)cmdloop():类似与Tkinter的m ...
- java面试题大全-基础方面
Java基础方面: 1.作用域public,private,protected,以及不写时的区别答:区别如下:作用域 当前类 同一package 子孙类 ...
- Amzon MWS API开发之 请求报告
时间一晃而过又过了两周,博客园更新的速度确实有点慢,今天我要分享的是对请求报告的调用. 在文档中,相信大家也看了下面这个流程图吧? 相关流程,在文档中也有细说,我就不一一去Copy了:http://d ...
- Ruby小例子
1.ruby定义函数与执行函数案例 def fact(n) ) end end print fact() 结果: 24 2.一个小例子 words = [)] print "guess?\n ...
- UDP包的大小与MTU
在进行UDP编程的时候,我们最容易想到的问题就是,一次发送多少bytes好?当然,这个没有唯一答案,相对于不同的系统,不同的要求,其得到的答案是不一样的,我这里仅对像ICQ一类的发送聊天消息的情况作分 ...