-문제점:
아래와 같은 flask코드가 있을때 클라이언트에서 get요청을 하면 아래의 @app.route가 실행되는줄알았다
@app.route("/tech")
def tech():
return render_template('tech.html')
@app.route("/tech", methods=["GET"])
def tech_get():
techList = list(db.tech.find({},{'_id':False}))
return jsonify({'techList':techList})
-알게된점:
app.route('/tech') 이렇게 메소드가 안써져있어도 디폴트가 GET방식인거같다
그렇게 판단한 이유는
@app.route('/tech')
def tech():
print(request.method)
return render_template('tech.html')
위 코드로 request.method를 출력해보면 GET으로 나온다
그러므로
@app.route('/tech') 와 @app.route('/tech', methods=['GET'])이것은 동시에 쓸수없다.
'TIL,WIL(일간,주간 회고)' 카테고리의 다른 글
2022. 12. 05 TIL 파이썬Flask app.py에서 바로 클라이언로 뿌려주기 (0) | 2022.12.06 |
---|---|
2022. 12. 05 TIL 파이썬 이미지소스 크롤링 문제 (0) | 2022.12.06 |
2022. 12. 05 TIL html 상단바 layer문제 (2) | 2022.12.06 |
2022. 12. 05 TIL html 상단바 위치 문제 (0) | 2022.12.06 |
2022. 12. 05 TIL html 상단바 안쪽 <a>테그 위치 문제 (0) | 2022.12.06 |