Python bottle minimal example
Minimal hello world-like example using the bottle HTTP server:
#!/usr/bin/env python3
from bottle import route, run
@route('/')
def index():
return "Hello bottle!"
run(host='localhost', port=9000)
Run this file (and keep it running) and then navigate to http://localhost:9000 to see the Hello bottle!
message.
In case you see this error message:
Traceback (most recent call last):
File "./server.py", line 2, in <module>
from bottle import route, run
ModuleNotFoundError: No module named 'bottle'
you need to install bottle
using
pip install -U bottle
depending on which Python version and configuration you use.
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow