Creating a view function without returning a response in Flask
flask, jquery, python, redis, sqlite
Solution
It's quite simple, just return an empty string with 204 status code:
@app.route('/')
def hello():
# ...
return '', 204
Problem
I'm rather new to web programming and Flask, and I've recently run into a problem with a website I am trying to create. I currently have a jquery procedure which sends a post request to a view function in Flask. This function simply increments a value in my database, and it's not really necessary for me to return a response after incrementing this value. However, as far as I've seen, view functions in Flask are required to return a Response object. I could of course trivially return some sort of json "was-updated" response, but it's really not important to my application. Does anyone know if the proper way to resolve this issue? Thanks.