Showing posts with label appengine. Show all posts
Showing posts with label appengine. Show all posts

Thursday, April 12, 2012

在App Engine上使用bottle框架

application: my-bottle-app\
version: 1
runtime: python
api_version: 1

handlers:
- url: /styles
static_dir: styles

- url: /.*
script: main.py

from framework import bottle
from framework.bottle import route, template, request, error, debug
from google.appengine.ext.webapp.util import run_wsgi_app

@route('/')
def DisplayForm():
message = 'Hello World'
output = template('templates/home', data = message)
return output

def main():
debug(True)
run_wsgi_app(bottle.default_app())

@error(403)
def Error403(code):
return 'Get your codes right dude, you caused some error!'

@error(404)
def Error404(code):
return 'Stop cowboy, what are you trying to find?'

if __name__=="__main__":
main()

Monday, September 8, 2008

绕过 GHS 用自定义域名发布 Blogger

! 这是一篇转载文章

2007年1月,Google Blogger 的自定义域名功能推出不到一个星期,就被 GFW 给废了。原因就是 GFW 隔断了国内用户对 Google 的免费主机托管服务 ghs.google.com 的访问。

今天试着将 App Engine 应用部署到自己域名的时候,发现 App Engine 不需要将 CNAME record 指向 ghs.google.com,从而可以避开 GFW。而同样的方法也可以适用于 Blogger。方法如下:

  1. 把 Blogger 的发布方式切换成“自定义域名(Custom Domain)”。在“你的域名(Your Domain)”一栏中填上域名,比如,py.thonic.org。保存设置(Save Settings)。

  2. 在你的域名注册商那里,修改域名(thonic.org)的 DNS 设置。为子域名(py)添加一条 A record,指向下面四个 IP 地址的其中之一。举例来说,就是添加这样一条记录:py.thonic.org 86400 IN A 216.239.34.21

    • 216.239.32.21

    • 216.239.34.21

    • 216.239.36.21

    • 216.239.38.21




DNS 设置的改动需要一段时间来完成,一般不会超过24小时。这样就可以重新使用 Blogger 的自定义域名功能了,只是,这次又可以持续多久呢?

我把上面的 IP 绑定到自己的域名了,ghs.luliban.com。以后也可以像 ghs.google.com 一样,添加一条 CNAME 记录到 ghs.luliban.com 来绑定 Google Blogger 或者 Google Apps 了。

Last Update: 2008/10/31