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 ...
随机推荐
- Windows上Python3.5安装Scrapy(lxml)
常用网址: Python 3.5: https://www.python.org/downloads/ Wheel文件:http://www.lfd.uci.edu/~gohlke/pythonlib ...
- jQuery的类数组对象结构
Query就是为了获取DOM.操作DOM而存在的 所以为了更方便这些操作,让节点与实例对象通过一个桥梁给关联起来,jQuery内部就采用了一种叫"类数组对象"的方式作为存储结构,所 ...
- JavaScript Infinite scroll & Masonry
// infinitescroll() is called on the element that surrounds // the items you will be loading more of ...
- coco2d-x中的坐标系问题
(1)OpenGL坐标系 Cocos2D-x以OpenGL和OpenGL ES为基础,所以自然支持OpenGL坐标系.该坐标系原点在屏幕左下角,x轴向右,y轴向上. (2)屏幕坐标系 屏幕坐标系使用的 ...
- *1022. D进制的A+B【考前最后一道题】
/* *Main.c *1022. D进制的A+B Ver.1 *Created on : 2014.9.5 *****测试通过****** */ #include <stdio.h> ...
- 多线程 NSThread GCD
ios多线程实现种类 NSThread NSOperationQueue NSObject GCD *************** 1.NSThread //线程 第一种 NSThread *thre ...
- JS面向对象编程之:封装、继承、多态
最近在实习公司写代码,被隔壁的哥们吐槽说,代码写的没有一点艺术.为了让我的代码多点艺术,我就重新温故了<javascript高级程序设计>(其中几章),然后又看了<javascrip ...
- sqlite在Android上的一个bug:SQLiteCantOpenDatabaseException when nativeExecuteForCursorWindow
更多内容在这里查看 https://ahangchen.gitbooks.io/windy-afternoon/content/ ::-/com.company.product W/System.er ...
- android 遇到的细节 FAQ
1.ListView 设置addHead 在3.0与之前版本若在:setAdapter之后添加,运行报错.4.0以后不报错 2.ListView Adapter getView函数忘记返回vi ...
- position:absolute实现垂直居中
一些图标通常要垂直居中 如下所示: 而css中没有直接的样式.需要我们自己调试. 我用了position:absolute;来实现. 要想使得position:absolute;有效,它的父元素必须也 ...