bottle - python web microframework
DESCRIPTION
Vorstellung des Python Web Microframeworks Bottle.TRANSCRIPT
![Page 1: Bottle - Python Web Microframework](https://reader037.vdocuments.net/reader037/viewer/2022103016/5552c1b6b4c905920f8b492d/html5/thumbnails/1.jpg)
Python Web Microframework
Markus Zapke-GründemannLeipzig Python User Group - 8.9.2009
![Page 2: Bottle - Python Web Microframework](https://reader037.vdocuments.net/reader037/viewer/2022103016/5552c1b6b4c905920f8b492d/html5/thumbnails/2.jpg)
![Page 3: Bottle - Python Web Microframework](https://reader037.vdocuments.net/reader037/viewer/2022103016/5552c1b6b4c905920f8b492d/html5/thumbnails/3.jpg)
Web Microframework
![Page 4: Bottle - Python Web Microframework](https://reader037.vdocuments.net/reader037/viewer/2022103016/5552c1b6b4c905920f8b492d/html5/thumbnails/4.jpg)
Python 2.5 oder 3.x
![Page 5: Bottle - Python Web Microframework](https://reader037.vdocuments.net/reader037/viewer/2022103016/5552c1b6b4c905920f8b492d/html5/thumbnails/5.jpg)
WSGI(Web Server Gateway Interface)
![Page 6: Bottle - Python Web Microframework](https://reader037.vdocuments.net/reader037/viewer/2022103016/5552c1b6b4c905920f8b492d/html5/thumbnails/6.jpg)
Routing
![Page 7: Bottle - Python Web Microframework](https://reader037.vdocuments.net/reader037/viewer/2022103016/5552c1b6b4c905920f8b492d/html5/thumbnails/7.jpg)
POST, GET, PUT, DELETE, HEAD
![Page 8: Bottle - Python Web Microframework](https://reader037.vdocuments.net/reader037/viewer/2022103016/5552c1b6b4c905920f8b492d/html5/thumbnails/8.jpg)
Cookies
![Page 9: Bottle - Python Web Microframework](https://reader037.vdocuments.net/reader037/viewer/2022103016/5552c1b6b4c905920f8b492d/html5/thumbnails/9.jpg)
Templates
![Page 10: Bottle - Python Web Microframework](https://reader037.vdocuments.net/reader037/viewer/2022103016/5552c1b6b4c905920f8b492d/html5/thumbnails/10.jpg)
Einfache Validatoren
![Page 11: Bottle - Python Web Microframework](https://reader037.vdocuments.net/reader037/viewer/2022103016/5552c1b6b4c905920f8b492d/html5/thumbnails/11.jpg)
Key/Value Datenbank
![Page 12: Bottle - Python Web Microframework](https://reader037.vdocuments.net/reader037/viewer/2022103016/5552c1b6b4c905920f8b492d/html5/thumbnails/12.jpg)
1 Datei936 Zeilen30460 Byte
![Page 13: Bottle - Python Web Microframework](https://reader037.vdocuments.net/reader037/viewer/2022103016/5552c1b6b4c905920f8b492d/html5/thumbnails/13.jpg)
MIT Lizenz
![Page 14: Bottle - Python Web Microframework](https://reader037.vdocuments.net/reader037/viewer/2022103016/5552c1b6b4c905920f8b492d/html5/thumbnails/14.jpg)
GitHub
![Page 15: Bottle - Python Web Microframework](https://reader037.vdocuments.net/reader037/viewer/2022103016/5552c1b6b4c905920f8b492d/html5/thumbnails/15.jpg)
bottle.paws.de
![Page 16: Bottle - Python Web Microframework](https://reader037.vdocuments.net/reader037/viewer/2022103016/5552c1b6b4c905920f8b492d/html5/thumbnails/16.jpg)
1 from bottle import route, run 2 3 @route('/') 4 def index(): 5 return 'Hello World!' 6 7 run()
Beispiel 1
![Page 17: Bottle - Python Web Microframework](https://reader037.vdocuments.net/reader037/viewer/2022103016/5552c1b6b4c905920f8b492d/html5/thumbnails/17.jpg)
1 from bottle import route, run 2 3 @route('/hello/:name') 4 def index(name): 5 return 'Hello %s!' % name 6 7 run()
Beispiel 2
![Page 18: Bottle - Python Web Microframework](https://reader037.vdocuments.net/reader037/viewer/2022103016/5552c1b6b4c905920f8b492d/html5/thumbnails/18.jpg)
1 from bottle import route, run, send_file 2 3 @route('/static/:filename') 4 def static_file(filename): 5 send_file(filename, root='/path/to/static/files') 6 7 run()
Beispiel 3
![Page 19: Bottle - Python Web Microframework](https://reader037.vdocuments.net/reader037/viewer/2022103016/5552c1b6b4c905920f8b492d/html5/thumbnails/19.jpg)
1 from bottle import route, run, send_file 2 3 @route(r'/static/(?P<filename>.*)') 4 def static_file(filename): 5 send_file(filename, root='/path/to/static/files') 6 7 run()
Beispiel 4
![Page 20: Bottle - Python Web Microframework](https://reader037.vdocuments.net/reader037/viewer/2022103016/5552c1b6b4c905920f8b492d/html5/thumbnails/20.jpg)
1 <html> 2 <head> 3 <title>Welcome!</title> 4 </head> 5 <body> 6 <h1>Welcome!</h1> 7 %for name in names: 8 <p>Hello {{name}}!</p> 9 %end 10 </body> 11 </html>
Beispiel 5 1 from bottle import route, run, template 2 3 @route('/welcome/:names') 4 def welcome(names): 5 names = names.split(',') 6 return template('welcome', names=names) 7 8 run()
![Page 21: Bottle - Python Web Microframework](https://reader037.vdocuments.net/reader037/viewer/2022103016/5552c1b6b4c905920f8b492d/html5/thumbnails/21.jpg)
1 from bottle import request, route, run 2 3 @route('/user-agent') 4 def user_agent(): 5 return request._environ.get('HTTP_USER_AGENT') 6 7 run()
Beispiel 6
![Page 22: Bottle - Python Web Microframework](https://reader037.vdocuments.net/reader037/viewer/2022103016/5552c1b6b4c905920f8b492d/html5/thumbnails/22.jpg)
1 from bottle import route, run 2 3 @route(r'/get_object/(?P<id>[0-9]+)') 4 def get_id(id): 5 return "Object ID: %d" % int(id) 6 7 @route(r'/get_object/(?P<slug>[-\w]+)') 8 def get_slug(slug): 9 return "Slug: %s" % slug 10 11 run()
Beispiel 7
![Page 23: Bottle - Python Web Microframework](https://reader037.vdocuments.net/reader037/viewer/2022103016/5552c1b6b4c905920f8b492d/html5/thumbnails/23.jpg)
1 from bottle import route, run, validate 2 3 @route('/validate/:id/:price/:csv') 4 @validate(id=int, price=float, csv=lambda x: map(int, x.split(','))) 5 def validate_args(id, price, csv): 6 return "Id: %d, Price: %f, List: %s" % (id, price, repr(csv)) 7 8 run()
Beispiel 8
![Page 24: Bottle - Python Web Microframework](https://reader037.vdocuments.net/reader037/viewer/2022103016/5552c1b6b4c905920f8b492d/html5/thumbnails/24.jpg)
Lizenz
Dieses Werk ist unter einem Creative Commons Namensnennung-Weitergabe unter gleichen
Bedingungen 3.0 Unported Lizenzvertrag lizenziert. Um die Lizenz anzusehen, gehen Sie bitte zu
http://creativecommons.org/licenses/by-sa/3.0/ oder schicken Sie einen Brief an Creative Commons, 171 Second Street, Suite 300, San Francisco, California
94105, USA.