プログラム
hello.py
from flask import Flask
app = Flask(__name__)
@app.route('/')
def index():
str_out = '<h2>こんにちは!</h2>'
str_out += '<p>Aug/15/2023</p>'
return str_out
app.run(host='0.0.0.0')
実行
python hello.py
実行した時の様子
$ python hello.py
* Serving Flask app 'hello'
* Debug mode: off
WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
* Running on all addresses (0.0.0.0)
* Running on http://127.0.0.1:5000
* Running on http://192.168.1.6:5000
Press CTRL+C to quit
クライアントでアクセス
確認したバージョン
$ flask --version
Python 3.12.3
Flask 3.0.2
Werkzeug 3.0.1