Size: 1609
Comment:
|
Size: 2383
Comment:
|
Deletions are marked like this. | Additions are marked like this. |
Line 13: | Line 13: |
= web.py 食谱 = * [http://webpy.org/cookbook web.py Cook Book] ~ 中文翻译 |
|
Line 64: | Line 67: |
* Sending Mail | == 邮件 == 命题:: * 如何通过 web.py 操作邮件? 解决:: * `web.sendmail`函式用以发送邮件 {{{ web.sendmail('[email protected]', '[email protected]', 'subject', 'message') }}} * 配置`web.config`可通过其它邮件服务发送比如:`/usr/lib/sendmail.` {{{ web.config.smtp_server = 'mail.mydomain.com' }}} * 可以在`to_address` 参数中指定多个地址 {{{ web.sendmail('[email protected]' , ['[email protected]', '[email protected]'] , 'subject', 'message') }}} * 使用`cc`和`bcc`键参数,则声明转发和暗送邮箱地址(使用列表,同樣支持多地址Cc Bcc) {{{ web.sendmail('[email protected]', '[email protected]', 'subject', 'message', cc='[email protected]', bcc='[email protected]') }}} |
Line 72: | Line 100: |
= web.py 食谱 = * [http://webpy.org/cookbook web.py Cook Book] ~ 中文翻译 |
http://webpy.org/static/webpy.gif WebPy ~ 超轻量WSGI 应用框架
::-- ZoomQuiet [DateTime(2008-02-24T06:19:46Z)] TableOfContents
web.py 0.3 的食谱格式文档.
1. web.py 食谱
[http://webpy.org/cookbook web.py Cook Book] ~ 中文翻译
1.1. Hello World!
- 命题
怎么使用web.py 写个hello world?
- 解决
1.2. 客户对话~Sessions
- 命题
web.session模块专门进行了支持,以下实例
1 import web
2 urls = (
3 "/count", "count",
4 "/reset", "reset"
5 )
6 app = web.application(urls, locals())
7 session = web.session.Session(app, web.session.DiskStore('sessions'), initializer={'count': 0})
8
9 class count:
10 def GET(self):
11 session.count += 1
12 return str(session.count)
13
14 class reset:
15 def GET(self):
16 session.kill()
17 return ""
18
19 if __name__ == "__main__":
20 app.run()
- 对话对象在响应请求句柄前加载,前在请求句柄后保存变更
initializer 参数用以初创对话
1.3. 邮件
- 命题
web.sendmail函式用以发送邮件
web.sendmail('[email protected]', '[email protected]', 'subject', 'message')
配置web.config可通过其它邮件服务发送比如:/usr/lib/sendmail.
web.config.smtp_server = 'mail.mydomain.com'
可以在to_address 参数中指定多个地址
web.sendmail('[email protected]' , ['[email protected]', '[email protected]'] , 'subject', 'message')
使用cc和bcc键参数,则声明转发和暗送邮箱地址(使用列表,同樣支持多地址Cc Bcc)
web.sendmail('[email protected]', '[email protected]', 'subject', 'message', cc='[email protected]', bcc='[email protected]')
- Using Site Layout Templates
- File Upload
Requests:
- How to properly use web.background