Skip to content

Instantly share code, notes, and snippets.

@orestis
Created February 3, 2014 16:44
Show Gist options
  • Save orestis/8787408 to your computer and use it in GitHub Desktop.
Save orestis/8787408 to your computer and use it in GitHub Desktop.
from bottle import Bottle, template, request, run
app = Bottle()
@app.route('/hello/')
def greet():
return template('''
<html>
<body>
Please introduce yourself:
<form action="/knock" method="POST">
<input type="text" name="name" />
<input type="submit" />
</body>
</html>''', name=name)
@app.post('/knock')
def knock():
name = request.forms.get('name')
# this is the only new code added in our wsgi app
app.broadcast_message("{} knocked".format(name))
return template("<p>{{ name }} Knocked!</p>", name=name)
wsgi_app = app
if __name__ == '__main__':
run(app, host='localhost', port=8005)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment