欢迎大家赞助一杯啤酒🍺 我们准备了下酒菜:Formal mathematics/Isabelle/ML, Formal verification/Coq/ACL2, C++/F#/Lisp
Web.py
小 (→0.3) |
|||
(未显示1个用户的40个中间版本) | |||
第1行: | 第1行: | ||
− | + | {{top news}} | |
+ | [[Image:webpy.png|right]] | ||
− | [[ | + | [[Image:webpy.gif|right]] |
+ | "[[Django]] lets you write web apps in Django. [[TurboGears]] lets you write web apps in TurboGears. Web.py lets you write web apps in [[Python]]." - Adam Atlas | ||
+ | ==0.3x== | ||
+ | 0.3x版本的开发, https://launchpad.net/webpy | ||
+ | |||
+ | ==Install== | ||
+ | wget http://webpy.org/web.py-0.2.tar.gz | ||
+ | python setup.py install // install to /usr/local/lib/python2.4/site-packages/web | ||
+ | touch code.py | ||
+ | import web | ||
+ | urls = ( | ||
+ | '/hello/webpy', 'index' | ||
+ | ) | ||
+ | class index: | ||
+ | def GET(self): | ||
+ | print "hello, webpy" | ||
+ | |||
+ | if __name__ == "__main__": web.run(urls, globals()) | ||
+ | |||
+ | python code.py | ||
+ | http://localhost:8080/hello/webpy :) | ||
+ | |||
+ | Build on Python 2.3 | ||
+ | File "utils.py", line 528 | ||
+ | return ''.join(c for c in str(string).split('.')[0] if c.isdigit()) | ||
+ | change to return ''.join([c for c in str(string).split('.')[0] if c.isdigit()]) | ||
+ | python setup.py install // ok :) | ||
+ | ==Template== | ||
+ | mkdir templates | ||
+ | cd templates | ||
+ | touch index.html | ||
+ | ==Database== | ||
+ | For MySQL databases, use [[MySQLdb]] and for Postgres use [[psycopg]]2. | ||
+ | web.config.db_parameters = dict(dbn='postgres', user='username', pw='password', db='dbname') | ||
+ | web.config.db_parameters = dict(dbn='mysql', user='username', pw='password', db='dbname') | ||
+ | ==Example== | ||
+ | *http://docs.huihoo.com/webpy/webpy-examples01.tar.gz | ||
+ | *http://docs.huihoo.com/webpy/simplewiki.zip | ||
+ | *http://docs.huihoo.com/webpy/simple-crud-postgresql.zip | ||
+ | *code samples http://webpy.infogami.com/src | ||
+ | ==常见用法== | ||
+ | import web | ||
+ | urls = ( | ||
+ | '/', 'index' ) | ||
+ | class index: | ||
+ | def GET(self): | ||
+ | print "Hello, world!" | ||
+ | |||
+ | web.internalerror = web.debugerror | ||
+ | web.header("Content-Type","text/html; charset=utf-8") | ||
+ | |||
+ | web.redirect(web.ctx.home+'/page/'+name) | ||
+ | if __name__ == "__main__": web.run(urls, globals()) | ||
+ | if __name__ == "__main__": web.run(urls, globals(), web.reloader) // more helpful error messages | ||
+ | |||
+ | $def with (name) | ||
+ | $if name: | ||
+ | I just wanted to say <em>hello</em> to $name. | ||
+ | $else: | ||
+ | <em>Hello</em>, world! | ||
+ | |||
+ | render = web.template.render('templates/') | ||
+ | cache=False | ||
+ | name = 'Huihoo' | ||
+ | print render.index(name) | ||
+ | |||
+ | i = web.input() | ||
+ | n = web.insert('todo', title=i.title) | ||
+ | web.seeother('/') | ||
+ | |||
+ | ==User== | ||
+ | *http://reddit.com - http://reddit.com/help/faq | ||
+ | So what Python framework did you use? | ||
+ | |||
+ | web.py, the web application framework of choice for discriminating hackers. web.py is itself built upon [[Cheetah]]. The data is stored in a [[PostgreSQL]] database and served by [[Lighttpd]]. | ||
+ | *[http://yandex.ru/ Yandex], a Russian traffic provider whose homepage alone receives 70 million daily page views, uses web.py for certain projects. | ||
+ | *http://infogami.com/ built in Python using web.py, [[PostgreSQL]], and [[Lighttpd]]. | ||
+ | *web.py wiki - http://webpy.infogami.com/ | ||
+ | *http://www.youos.com | ||
+ | "We completed our server rewrite a few days ago with web.py and it was everything we could have wished for." - Sam Hsiung, YouOS | ||
+ | *http://delaunay.org/antoine/i , [http://trac.delaunay.org/browser/srv/www.delaunay.org/antoine/i/ source] | ||
+ | ==Links== | ||
+ | *http://webpy.org/ | ||
+ | *http://webpy.infogami.com/ | ||
+ | *http://groups.google.com/group/webpy | ||
+ | *https://code.launchpad.net/webpy/ | ||
+ | *http://download.huihoo.com/webpy/ | ||
+ | *http://docs.huihoo.com/webpy/ | ||
+ | |||
+ | {{comment}} | ||
+ | |||
+ | [[Category:Framework]] | ||
+ | [[Category:Python]] |
2010年12月3日 (五) 15:26的最后版本
"Django lets you write web apps in Django. TurboGears lets you write web apps in TurboGears. Web.py lets you write web apps in Python." - Adam Atlas
目录 |
[编辑] 0.3x
0.3x版本的开发, https://launchpad.net/webpy
[编辑] Install
wget http://webpy.org/web.py-0.2.tar.gz python setup.py install // install to /usr/local/lib/python2.4/site-packages/web touch code.py import web urls = ( '/hello/webpy', 'index' ) class index: def GET(self): print "hello, webpy" if __name__ == "__main__": web.run(urls, globals()) python code.py http://localhost:8080/hello/webpy :)
Build on Python 2.3
File "utils.py", line 528 return .join(c for c in str(string).split('.')[0] if c.isdigit()) change to return .join([c for c in str(string).split('.')[0] if c.isdigit()]) python setup.py install // ok :)
[编辑] Template
mkdir templates cd templates touch index.html
[编辑] Database
For MySQL databases, use MySQLdb and for Postgres use psycopg2.
web.config.db_parameters = dict(dbn='postgres', user='username', pw='password', db='dbname') web.config.db_parameters = dict(dbn='mysql', user='username', pw='password', db='dbname')
[编辑] Example
- http://docs.huihoo.com/webpy/webpy-examples01.tar.gz
- http://docs.huihoo.com/webpy/simplewiki.zip
- http://docs.huihoo.com/webpy/simple-crud-postgresql.zip
- code samples http://webpy.infogami.com/src
[编辑] 常见用法
import web urls = ( '/', 'index' ) class index: def GET(self): print "Hello, world!"
web.internalerror = web.debugerror web.header("Content-Type","text/html; charset=utf-8")
web.redirect(web.ctx.home+'/page/'+name) if __name__ == "__main__": web.run(urls, globals()) if __name__ == "__main__": web.run(urls, globals(), web.reloader) // more helpful error messages
$def with (name) $if name: I just wanted to say hello to $name. $else: Hello, world!
render = web.template.render('templates/') cache=False name = 'Huihoo' print render.index(name)
i = web.input() n = web.insert('todo', title=i.title) web.seeother('/')
[编辑] User
So what Python framework did you use?
web.py, the web application framework of choice for discriminating hackers. web.py is itself built upon Cheetah. The data is stored in a PostgreSQL database and served by Lighttpd.
- Yandex, a Russian traffic provider whose homepage alone receives 70 million daily page views, uses web.py for certain projects.
- http://infogami.com/ built in Python using web.py, PostgreSQL, and Lighttpd.
- web.py wiki - http://webpy.infogami.com/
- http://www.youos.com
"We completed our server rewrite a few days ago with web.py and it was everything we could have wished for." - Sam Hsiung, YouOS
[编辑] Links
- http://webpy.org/
- http://webpy.infogami.com/
- http://groups.google.com/group/webpy
- https://code.launchpad.net/webpy/
- http://download.huihoo.com/webpy/
- http://docs.huihoo.com/webpy/
<discussion>characters_max=300</discussion>