ファイル構造
ProjectFile/
├ main.py/
├ templates/
└ css/
└ style.css/
Pythonファイル
import flask
from flask import render_template
app = flask.Flask(__name__,
static_folder='./templates/css')
@app.route('/')
def index():
return render_template('index.html')
if __name__ == '__main__':
app.run(debug=True)
HTMLファイル
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<link rel='stylesheet' href='css/style.css'>
</head>
<body>
<h1>Hello World</h1>
</body>
</html>
CSSファイル
body {
background-color: antiquewhite;
}
h1 {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
font-family: 'Times New Roman', Times, serif;
}