Thinking "I want to make a web application ...", is there a good framework for Python that I'm currently studying? When I looked it up ...
I found something called Bottle, so make a note of it up to Hello Word.
yum update Well, it's basic, so let's do it.
# sudo yum update
Loaded plugins: priorities, update-motd, upgrade-helper
No packages marked for update
Yeah, the new server is nice.
After investigating various things, I placed the Bottle body with wget ... But I believe in the official documentation! !!
# pip install bottle
You are using pip version 6.1.1, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Collecting bottle
100% |******************************| 73kB 4.0MB/s
Installing collected packages: bottle
Running setup.py install for bottle
Successfully installed bottle-0.12.13
Alright, especially Ppoi!
Use the one in the middle of the Bottle page. Example: “Hello World” in a bottle
Let's make it with an appropriate name.
main_app.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)
Don't forget!
# chmod +x ./main_app.py
Let's move it!
# python main_app.py
Bottle v0.12.13 server starting up (using WSGIRefServer())...
Listening on http://localhost:8080/
Hit Ctrl-C to quit.
Oh! I started listening. Well, try duplicating the terminal and curl it.
$ curl http://localhost:8080/hello/jump
<b>Hello jump</b>!
Hello! !!
The access log is returned to the terminal that was run.
127.0.0.1 - - [29/Jun/2017 09:48:38] "GET /hello/jump HTTP/1.1" 200 18
I even tried Hello Word from Bottle. You should read the official document, right? I think you can hear the voice saying ... I hope it helps someone.
For the time being, it was Qiita's first post, so I wrote it after practicing, ** Qiita is wonderful! !! **: relaxed: I want to continue in the future!
Recommended Posts