目標
環境
- Windows 10 Pro
- Python 3.7.5
- flask 1.1.1
ディレクトリ構成
ソースコード
index.html
はVSCode上でEmmetで!
と打ってtabで展開したものに<h1>Hello, world!</h1>
を書いただけ。
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<h1>Hello, world!</h1>
</body>
</html>
sample.py
でport='5555'
としてるのに特に理由はない。
from flask import Flask, render_template
# インスタンス化
app = Flask(__name__)
@app.route('/')
def index():
return render_template('index.html');
if __name__ == '__main__':
app.run(host='0.0.0.0', port='5555', debug=True)
起動
>python sample.py