Just writing a Python script doesn't help keep you motivated. I want to use a script written in Python as a web application. I want to see it running in my browser!
Bottle is a very effective framework in such cases. I've been doing bottle missionary activities recently, so
For those people. I will explain it because it seems that there are many cases where you try to install with pip and stumble.
$ pip install bottle
This is a big mistake in the first place. Of course, this will not work unless it is in a virtual environment.
The bottle consists of just one .py file. As a general rule, bottle should be "in the same hierarchy" as the Python script file you are about to create. Must be installed.
So it's easy to save bottle.py as is.
https://raw.githubusercontent.com/bottlepy/bottle/master/bottle.py
Save this source as bottle.py. As a folder hierarchy,
myapp/ bottle.py
index.py
It looks like.
If you can do so far, write the contents of index.py in the same way as the official one.
index.py
from bottle import route, run, template
@route('/hello/<name>')
def index(name):
return template('<b>Hello {{name}}</b>!', name=name)
run(host='localhost', port=8080)
$ cd myapp
$ python index.py
It's OK if you access http: // localhost: 8080 / hello / world and it works.
It's very thin, but I've put it together in a book. https://www.amazon.co.jp/dp/B01MQU38Y0
It's almost the same as a bottle. http://qiita.com/Gen6/items/ff1d163acf0fa7687454
I've put it together in a book as usual. https://www.amazon.co.jp/dp/B0714D1VGP