Skip to content

Instantly share code, notes, and snippets.

@maxp
Created January 23, 2013 05:02
Show Gist options
  • Select an option

  • Save maxp/4602156 to your computer and use it in GitHub Desktop.

Select an option

Save maxp/4602156 to your computer and use it in GitHub Desktop.
botttle.py sample
#!/usr/bin/python
# coding: utf-8
from bottle import get, post, route, run, template, request, redirect
posts = []
form_html = \
"""
<form method=POST action="form">
<input type="text" name="text" />
</form>
"""
@get('/')
def index():
return str(posts)+"<hr/>"+form_html
@post('/form')
def form():
print "text:", request.forms.get("text")
posts.append( request.forms.get("text") )
redirect("/")
run(host='localhost', port=8080)
#.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment