uri์ ๋์ ์ถ๊ฐ๋ username์ด ๋์ ์ผ๋ก ๋ณ๊ฒฝ๋๋ ๋ถ๋ถ์ด๋ค.
<๋ณํํ์
: ๋ณ์๋ช
> ํํ๋ก ์ฌ์ฉ ๊ฐ๋ฅํ๋ฉฐ, string์ด ์๋ intํ์ด๋, ๊ธฐํ ๋ค๋ฅธํํ๋ก๋ ๋ณํํ์ฌ ์ฌ์ฉ ๊ฐ๋ฅํ๋ค.
app.py
from flask import Flask , render_template
app = Flask(__name__)
@app.route("/profile/<username>")
def profil(username):
return render_template(username)
if __name__ == "__main__":
app.run(host = "127.0.0.1", port=5000, debug = True)
home.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>profile</title>
</head>
<body>
<h1>user profile search</h1>
<form method = "POST">
<input type="text" name = 'username'>
<button type="submit" method="POST" >๊ฒ์</button>
</form>
</body>
</html>
*์ถ๊ฐ์ ์ผ๋ก
๋์ ์ผ๋ก uri๋ฅผ ์ฌ์ฉํ๋ ๋ฐฉ๋ฒ์ค์๋
url_for() ํจ์๋ฅผ ์ด์ฉํ๋ ๋ฐฉ๋ฒ๋ ์๋ค๊ณ ํ๋ค. (๋์ค์ ํ๋ฒ ์ฐพ์๋ณด์)