
* 겪고 있는 문제 상황을 최대한 자세하게 작성해주세요.
* 문제 해결을 위해 어떤 시도를 해보았는지 구체적으로 함께 알려주세요.
강사님과 동일하게 했다고 생각하는데, Error 가 나네요. 여러번 봤는데도 뭔지 모르겠어요.

from flask import Flask, render_template, request, jsonify
app = Flask(__name__)
@app.route('/')
def home():
return render_template('index.html')
@app.route("/mars", methods=["POST"])
def web_mars_post():
sample_receive = request.form['sample_give']
print(sample_receive)
return jsonify({'msg': 'POST 연결 완료!'})
@app.route("/mars", methods=["GET"])
def web_mars_get():
return jsonify({'msg': 'GET 연결 완료!'})
if __name__ == '__main__':
app.run('0.0.0.0', port=5000, debug=True)
C:\Users\yklwm\AppData\Local\Programs\Python\Python38\python.exe C:\Users\yklwm\Desktop\sparta\projects\mars\app.py
* Serving Flask app 'app'
* Debug mode: on
WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
* Running on all addresses (0.0.0.0)
* Running on http://127.0.0.1:5000
* Running on http://192.168.0.160:5000
Press CTRL+C to quit
* Restarting with stat
* Debugger is active!
* Debugger PIN: 132-288-945
127.0.0.1 - - [19/Jan/2023 18:51:41] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [19/Jan/2023 18:51:41] "GET /mars HTTP/1.1" 200 -
127.0.0.1 - - [19/Jan/2023 18:51:46] "POST /mars HTTP/1.1" 500 -
Traceback (most recent call last):
File "C:\Users\yklwm\AppData\Local\Programs\Python\Python38\lib\site-packages\flask\app.py", line 2548, in __call__
return self.wsgi_app(environ, start_response)
File "C:\Users\yklwm\AppData\Local\Programs\Python\Python38\lib\site-packages\flask\app.py", line 2528, in wsgi_app
response = self.handle_exception(e)
File "C:\Users\yklwm\AppData\Local\Programs\Python\Python38\lib\site-packages\flask\app.py", line 2525, in wsgi_app
response = self.full_dispatch_request()
File "C:\Users\yklwm\AppData\Local\Programs\Python\Python38\lib\site-packages\flask\app.py", line 1822, in full_dispatch_request
rv = self.handle_user_exception(e)
File "C:\Users\yklwm\AppData\Local\Programs\Python\Python38\lib\site-packages\flask\app.py", line 1820, in full_dispatch_request
rv = self.dispatch_request()
File "C:\Users\yklwm\AppData\Local\Programs\Python\Python38\lib\site-packages\flask\app.py", line 1796, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
File "C:\Users\yklwm\Desktop\sparta\projects\mars\app.py", line 10, in web_mars_post
sample_receive = request.form['sample_give']
File "C:\Users\yklwm\AppData\Local\Programs\Python\Python38\lib\site-packages\werkzeug\datastructures.py", line 375, in __getitem__
raise exceptions.BadRequestKeyError(key)
werkzeug.exceptions.BadRequestKeyError: 400 Bad Request: The browser (or proxy) sent a request that this server could not understand.
KeyError: 'sample_give'
