[转]web.py在GAE上运行的例子--一个留言本
来源:互联网 发布:企业软件防火墙排名 编辑:程序博客网 时间:2024/05/01 01:02
http://webpy.appspot.com/
# app.yaml
application: webpy
version: 1
runtime: python
api_version: 1
handlers:
- url: /.*
script: code.py
## code.py
import web
from google.appengine.ext import db
urls = (
'/', 'index',
'/note', 'note',
'/source', 'source',
'/crash', 'crash'
)
render = web.template.render('templates/')
class Note(db.Model):
content = db.StringProperty(multiline=True)
date = db.DateTimeProperty(auto_now_add=True)
class index:
def GET(self):
notes = db.GqlQuery("SELECT * FROM Note ORDER BY date DESC LIMIT 10")
return render.index(notes)
class note:
def POST(self):
i = web.input('content')
note = Note()
note.content = i.content
note.put()
return web.seeother('/')
class source:
def GET(self):
web.header('Content-Type', 'text/plain')
return (
'## code.py/n/n' +
file('code.py').read() +
'/n/n## templates/index.html/n/n' +
file('templates/index.html').read()
)
class crash:
def GET(self):
import logging
logging.error('test')
crash
app = web.application(urls, globals())
main = app.cgirun()
## templates/index.html
$def with (notes)
<h1>Hello, world!</h1>
<h2>last 10 notes</h2>
$for note in notes:
<p>$note.content <span style="color: gray">($note.date)</span></p>
<h2>add a note</h2>
<form method="post" action="/note">
<textarea name="content"></textarea><br />
<button type="submit">save</button>
<h2>about this site</h2>
<p>This is a web.py example app, demonstrating that it works fine with Google App Engine. <a href="/source">View the source.</a></p>
<address>
<a href="http://www.aaronsw.com/">Aaron Swartz</a> for <a href="http://webpy.org/">web.py</a>
</address>
- [转]web.py在GAE上运行的例子--一个留言本
- 在GAE(Google App Engine)上搭建python2.7的web.py程序
- 一个运行在Web服务器上的远程管理简单例子
- web.py+sqlite写的简单留言本
- web.py+sqlite写的简单留言本
- 在GAE中使用web.py
- 一个php作的文本留言本的例子(五)
- 一个php作的文本留言本的例子(六)
- 一个php作的文本留言本的例子(四)
- 一个php作的文本留言本的例子(二)
- 一个php作的文本留言本的例子(三)
- 一个php作的文本留言本的例子(一)
- 一个ASP.NETXML留言本例子
- 一个ASP.NETXML留言本例子
- 在GAE上应用liftweb(scala的web框架)
- 简单的php留言本例子温习
- python在web.py运行
- Web Storage实现简单的留言本
- 解压了PDF 的stream部分,却不想继续分析了
- 请教 indexOF的用法
- access 中空值的判断
- 自己的大脑要有一个编程的思维
- C++ + Irrlicht整一个东东?
- [转]web.py在GAE上运行的例子--一个留言本
- 页面跳转返回问题
- 今天好高兴
- 一位硕士毕业生三个月求职经历与经验的结晶
- linux下压缩与解压缩的简单记忆方法;递归删除文件夹
- 编译C代码为python模块(pyd)
- 数据库对象的缓存策略
- 离婚的账单
- 引用 JSP:contentType 与pageEncoding区别