I'd like to send a local REST request in a flask app, like this:
from flask import Flask, url_for, request
import requests
app = Flask(__name__)
@app.route("/<name>/hi", methods=["POST"])
def hi_person(name):
form = {"name": name}
return requests.post(url_for("hi", _external=True), data=form)
@app.route("/hi", methods=["POST"])
def hi():
return 'Hi, %s!' % request.form["name"]
Sending curl -X POST http://localhost:5000/john/hi
causes the entire flask app to freeze. When I send a kill signal, I get a broken pipe error. Is there a way to prevent flask from freezing here?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…