I'm trying out Flask, I have this code:
responseDict = {}
responseDict["_hits"] = {}
app = Flask(__name__)
@app.route('/server')
def showMain():
query = request.args.get('q')
responseDict["_hits"]["random string here"] = query
return jsonify(responseDict)
Example:
- I make a simple GET
/server?q=earth
- I make another GET
/server?q=moon
I get the correct _hits
dictionary with the query I provided, but when I make the GET /server?q=moon
I also get the previous query, earth
How do I delete everything on responseDict
when the request is done?
Edit:
responseDict
has to be a global variable because it's used for server logging.