작성
·
218
0
구구단 출력 문제인데 질문이 있습니다.
from flask import Flask
from flask import render_template
from flask import redirect
from flask import request
from flask import url_for
app = Flask(__name__)
@app.route("/")
@app.route("/<int:num>", methods=['POST', 'GET'])
def gugudan(num=None):
if request.method == 'GET':
return render_template('index.html', gugudan=None)
else:
temp = request.form['input']
return render_template('index.html', gugudan=temp)
if __name__ == "__main__":
app.run(debug=True)
index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="{{ url_for('static', filename='file.css') }}">
</head>
<body>
<form action="/" method="POST">
<p><input type="text"/ id="input" value="name"><input type="submit"></button></p>
<form>
{% if gugudan == None%}
<p>Have to Type number</p>
{% else %}
<p>숫자가 입력되었습니다</p>
{% endif %}
</body>
</html>
위와 같이 main.py에서 method 타입을 2가지로 나눠서 한번에 처리도 가능할거라 생각했는데, method not allowed가 나오네요.
혹시 무엇이 문제일까요?
답변