Skip to content

Instantly share code, notes, and snippets.

@ramalho
Created November 21, 2011 21:23
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ramalho/1383988 to your computer and use it in GitHub Desktop.
Save ramalho/1383988 to your computer and use it in GitHub Desktop.
from 0 to Web in 35 lines
luciano@vogon:~$ sudo easy_install bottle
[sudo] password for luciano:
Searching for bottle
Reading http://pypi.python.org/simple/bottle/
Reading http://bottlepy.org/
[...]
Reading http://github.com/defnull/bottle
Best match: bottle 0.9.7
Downloading http://pypi.python.org/packages/source/b/bottle/bottle-0.9.7.tar.gz#md5=eb4faa6a519251928e4bb737db4217ae
Processing bottle-0.9.7.tar.gz
Running bottle-0.9.7/setup.py -q bdist_egg --dist-dir /tmp/easy_install-ZS8yDb/bottle-0.9.7/egg-dist-tmp-iQ53gN
zip_safe flag not set; analyzing archive contents...
bottle: module references __file__
bottle: module references __path__
Adding bottle 0.9.7 to easy-install.pth file
Installed /usr/local/lib/python2.7/dist-packages/bottle-0.9.7-py2.7.egg
Processing dependencies for bottle
Finished processing dependencies for bottle
luciano@vogon:~$ cat > hello.py
from bottle import route, run
@route('/hello/:name')
def index(name='World'):
return '<b>Hello %s!</b>' % name
run(host='localhost', port=8080)
luciano@vogon:~$ python hello.py &
[1] 19215
luciano@vogon:~$ Bottle server starting up (using WSGIRefServer())...
Listening on http://localhost:8080/
Use Ctrl-C to quit.
luciano@vogon:~$ curl Listening on http://localhost:8080/hello/Roberta
localhost - - [21/Nov/2011 19:20:24] "GET /hello/Roberta HTTP/1.1" 200 21
<b>Hello Roberta!</b>luciano@vogon:~$
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment