參考資料:
(1) https://www.instructables.com/id/Python-WebServer-With-Flask-and-Raspberry-Pi/
(2) https://medium.com/@rovai/python-webserver-with-flask-and-raspberry-pi-398423cc6f5d
(1) Installing FLASK and Setting Your RPi WebServer
sudo apt-get update sudo pip install Flask
(2) Create folder
(2.0) cd Documents
(2.1) mkdir rpiWebServer
(2.2) cd rpiWebServer
(2.3) mkdir static
(2.4) mkdir templates
(3) Create helloWorld.py
from flask import Flask app = Flask(__name__) @app.route("/") def hello(): return "Hello World!"
if __name__ == '__main__': app.run(debug=True, port=80, host='0.0.0.0')
The final folder “tree”, will look like:
(4) Execute Hello World program
pi@scpi:~/Documents/rpiWebServer $ sudo python helloWorld.py
* Serving Flask app "helloWorld" (lazy loading)
* Environment: production
WARNING: Do not use the development server in a production environment.
Use a production WSGI server instead.
* Debug mode: on
* Running on http://0.0.0.0:80/ (Press CTRL+C to quit)
* Restarting with stat
* Debugger is active!
* Debugger PIN: 159-728-082
(5) in WebBrower keyin
http://192.168.0.110/
留言列表