How to use the framework bottle. I confirmed it on Arch Linux.
Installation
yay python-bottle
yay python-jinja
program
greetings.py
#! /usr/bin/python
#
from bottle import route, run
@route('/hello')
def hello():
str_out = "Hello World!<br />"
str_out += "<blockquote>"
str_out += "Hello.<br />"
str_out += "</blockquote>"
str_out += "Nov/11/2020<br />"
return str_out
#
@route('/morning')
def morning():
str_out = "Good Morning!<br />"
str_out += "<blockquote>"
str_out += "Good morning.<br />"
str_out += "</blockquote>"
str_out += "Nov/11/2020<br />"
return str_out
#
@route('/evening')
def evening():
str_out = "Good Evening!<br />"
str_out += "<blockquote>"
str_out += "tonight.<br />"
str_out += "</blockquote>"
str_out += "Nov/11/2020<br />"
return str_out
#
run(host='localhost', port=8080, debug=True)
Run
$ ./greetings.py
Bottle v0.12.18 server starting up (using WSGIRefServer())...
Listening on http://localhost:8080/
Hit Ctrl-C to quit.
Access http: // localhost: 8080 / hello with a browser
Access http: // localhost: 8080 / morning with a browser
Access http: // localhost: 8080 / evening with a browser
I confirmed it in the next version.
$ python
Python 3.8.6 (default, Sep 30 2020, 04:00:38)
[GCC 10.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import bottle
>>> print(bottle.__version__)
0.12.18
Recommended Posts