Skip to Content
Python 技術手冊 第三版
book

Python 技術手冊 第三版

by lex Martelli, Anna Martelli Ravenscroft, Steve Holden
January 2018
Intermediate to advanced content levelIntermediate to advanced
856 pages
17h 17m
Chinese
GoTop Information, Inc.
Content preview from Python 技術手冊 第三版
658
|
20 章 HTTP 網路服務
t = bottle.template('tp.html', x=23)
return t
@bottle.route('/c')
@bottle.view('tp.html')
def c():
return {'x': 23}
如果 Bottle 內建的功能性(加上你能明確使用標準程式庫和第三方模組為
你自己建置的那些)還不夠,Bottle 也能讓你透過
plug-ins
外掛
擴充
它的功能。Bottle 正式認可並列出了超過十數個可重複使用的第三方 plug-
ins
http://bottlepy.org/docs/dev/plugins/index.html
),還有說明文件(
http://
bottlepy.org/docs/dev/plugindev.html
)介紹如何撰寫你自己的個人外掛。我
們沒有在本書中涵蓋 Bottle plug-ins
範例 20-3 展示了一個簡單的 Bottle 實例。
範例
20-3
 
一個
Bottle
實例
import datetime, bottle
one_year = datetime.timedelta(days=365)
@bottle.route('/')
def greet():
lastvisit = bottle.request.get_cookie('lastvisit')
now = datetime.datetime.now()
newvisit = now.ctime()
thisvisit ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

測試驅動開發|使用 Python

測試驅動開發|使用 Python

Harry J.W. Percival
Linux 内核观测技术BPF

Linux 内核观测技术BPF

David Calavera, Lorenzo Fontana

Publisher Resources

ISBN: 9789864766819