For: blueberry 0.1 only
Deprecated docs as of 0.2
- See examples directory in blueberry-0.2 distribution for a current example.
Some Basic Examples
Hello, World!
from blueberry import web
from blueberry.deploy import start
class Index(web.RequestHandler):
def get(self):
return "Hello, world"
urls = [
(r'/', Index)
]
app = web.WSGIApplication(urls, debug=True)
start(app, reloader=True)Basic HTML Forms
from blueberry import web, request
from blueberry.deploy import start
class Index(web.RequestHandler):
"""
RequestHandler classes implement functions for the HTTP methods. The WSGIApplication
class handles routing to the Index class and its methods based on the HTTP request.
"""
def get(self):
return """
<form action="/" method="post">
<p><label for="firstname">Firstname:</label>
<input type="text" name="firstname" id="firstname" /></p>
<input type="submit" />
</form>
"""
def post(self):
return "You entered: %s" % request.POST.get('firstname')
urls = [
(r'/', Index)
]
app = web.WSGIApplication(urls, debug=True)
start(app, reloader=True)