posted on April 22, 2011
Here’s some hello world code to get started with webpy.
#!/usr/bin/env python
import web
= lambda message: '<html><body>%s</body></html>'%message
render_html = (
urls '/(.*)', 'hello'
)= web.application(urls, globals())
app
class hello:
def GET(self, name):
if not name:
= 'world'
name return render_html('Hello, ' + name + '!')
if __name__ == "__main__":
app.run()
% ./webpydemo.py
http://0.0.0.0:8080/
% curl localhost:8080
<html><body>Hello, world!</body></html>
% curl localhost:8080/vh4x0r
<html><body>Hello, vh4x0r!</body></html>
</code>