Python bottle: Minimales Beispiel
English
Deutsch
Minimales Hello World-Beispiel mit dem bottle HTTP-Server:
bottle_hello.py
#!/usr/bin/env python3
from bottle import route, run
@route('/')
def index():
return "Hello bottle!"
run(host='localhost', port=9000)Führen Sie diese Datei aus (und lassen Sie sie laufen) und navigieren Sie dann zu http://localhost:9000, um die Hello bottle!-Nachricht zu sehen.
Falls Sie diese Fehlermeldung sehen:
bottle_module_error.txt
Traceback (most recent call last):
File "./server.py", line 2, in <module>
from bottle import route, run
ModuleNotFoundError: No module named 'bottle'müssen Sie bottle installieren mit
install_bottle.sh
pip install -U bottleje nachdem, welche Python-Version und Konfiguration Sie verwenden.
Check out similar posts by category:
Python
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow