How to Create a POST Request with Body Parameters in Flask? or Flask: How to Properly Create a POST R

20 Replies, 1145 Views

Dude, I feel you. Flask’s request handling can be weird. Try this:

```python
@app.route('/submit', methods=['POST'])
def submit():
if not request.is_json:
return "Not JSON!", 400
data = request.get_json()
return data
```

This way, you’ll know if the request isn’t even JSON.

Messages In This Thread



Users browsing this thread: 1 Guest(s)