<플라스크 자습 : 간단한 홈페이지 만든 것 구현하는지 올려보기>
python hello.py
<!DOCTYPE html>
<html lang="en">
<head>
<style>
h1{
font-size: 2rem;
color : Blue;
}
ul{
font-size : 1rem;
color : skyblue;
}
</style>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Home</title>
</head>
<body>
<h1>WebFrameWork</h1>
<p>
<ul>
<li><a href="1.html">Flask</a></li>
<li><a href="2.html">Django</a></li>
<li><a href="3.html">React</a></li>
</ul>
</p>
</body>
</html>
렌더링 한 결과
app.py
from flask import Flask, render_template
app = Flask(__name__)
@app.route('/')
def index():
return render_template("index.html")
@app.route('/1.html')
def subpage1():
return render_template("1.html")
@app.route('/2.html')
def subpage2():
return render_template("2.html")
@app.route('/3.html')
def subpage3():
return render_template("3.html")
if __name__ == '__main__':
app.run(debug = True)
아쉬운 점 : for 반복문으로 저 url을 정리하고 싶은데 마땅히 방법이 없는 것 같다. 실력이 더 쌓이면 알게 될 거 같긴 하다.
고민한 점 : 위의 내용 + url은 이름 그대로 만들어야 장소와 상관없이 뜬다.