简体   繁体   中英

Python POST requests executed twice on Flask App

I have Flask App deployed with nginx and gunicorn.

while requesting post request from my flask app, it is executed twice.

@app.route("/search", methods=['POST'])
def search():
        r = requests.post('http://localhost:6800/schedule.json', data='{"project":"rental", "spider":"airbnb"}')
        return json.dumps(r.json())

Here 2 different spider jobs are created.

It is because that the reloader spawns two processes when you run it. You can disable it by settting debug=False or use_reloader=False when you are running it.

Check out the answers of the questions:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM