노마드 코더 따라하기(get요청만)
2022. 3. 12. 18:38ㆍBackEnd/Flask (출처:시니어 개발) - 클론코딩
root 구조
main.py
from flask import Flask,render_template,request,redirect
app = Flask("SuperScrapper")
@app.route("/")
def main():
return render_template("potato.html")
@app.route("/report")
def report():
word =request.args.get('word')
if word:
word = word.lower()
else:
return redirect("/")
return render_template("report.html",searchingBy=word)
@app.route("/<username>")
def name(username):
return f"Hello your name is {username}"
app.run(host="0.0.0.0")
templates > potato.html
<!DOCTYPE html>
<html>
<head>
<title>Job Search</title>
</head>
<body>
<h1>Job Search</h1>
<form action="/report" method="get">
<input placeholder="what jod do you want?" required name="word" />
<button>Search</button>
</form>
</body>
</html>
templates > report.html
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<h1>Search Result</h1>
<h3>You are looking for {{searchingBy}}</h3>
</body>
</html>
'BackEnd > Flask (출처:시니어 개발) - 클론코딩' 카테고리의 다른 글
S3 file upload 예시 flask (0) | 2022.03.27 |
---|---|
이미지 리사이징 - flask (0) | 2022.03.26 |
config => app.config (0) | 2022.03.12 |
플라스크 기초 및 웹서버 개발의 개념 이해(2019.3) (0) | 2022.02.27 |