Thursday 25 April 2013

Create a Website in Python in 30sec

With a small 1 file lib called BottlePy and nothing else but standard Python install you can create a website in less than 30se.

  • Download bottle.py file here bottle.py on GitHub
  • Create a python script example.py
  • Put bottle.py in the same folder
  • Copy paste the HelloWord example
from bottle import route, run, template

@route('/hello/:name')
def index(name='World'):
    return template('Hello {{name}}!', name=name)

run(host='localhost', port=8080)
 


Bottle can even work with an Apache server in front of it as a WSGI app.
Why use Tx, GTK or QT  for your scripts ui when you can have a lightweight multiplatform web ui in 4 lines of code ?


No comments:

Post a Comment