Request not being executed
up vote
0
down vote
favorite
I'm trying to execute a request inside a route:
@app.route('/products')
@cross_origin(origin='*')
def get_products():
query = request.args.get('q')
# endpoint = endpoint_search.format(query)
endpoint = endpoint_search
res = requests.get(endpoint)
if res.status_code == 200:
json_search = res.json()
return json_search
else:
pass
if __name__ == '__main__':
app.run(debug=True, host='0.0.0.0', threaded=True)
But the server stays in idle until reach timeout. Why this is happening?
python flask request
add a comment |
up vote
0
down vote
favorite
I'm trying to execute a request inside a route:
@app.route('/products')
@cross_origin(origin='*')
def get_products():
query = request.args.get('q')
# endpoint = endpoint_search.format(query)
endpoint = endpoint_search
res = requests.get(endpoint)
if res.status_code == 200:
json_search = res.json()
return json_search
else:
pass
if __name__ == '__main__':
app.run(debug=True, host='0.0.0.0', threaded=True)
But the server stays in idle until reach timeout. Why this is happening?
python flask request
You are not returning anything in theelse
block. So ifres.status_code == 201
, then you don't actually do anything. You need to have a response for ALL branches of anif-else
.
– Jabari Dash
Nov 21 at 17:35
@JabariDash the problem is that the request is never being triggered.
– olegario
Nov 21 at 17:48
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I'm trying to execute a request inside a route:
@app.route('/products')
@cross_origin(origin='*')
def get_products():
query = request.args.get('q')
# endpoint = endpoint_search.format(query)
endpoint = endpoint_search
res = requests.get(endpoint)
if res.status_code == 200:
json_search = res.json()
return json_search
else:
pass
if __name__ == '__main__':
app.run(debug=True, host='0.0.0.0', threaded=True)
But the server stays in idle until reach timeout. Why this is happening?
python flask request
I'm trying to execute a request inside a route:
@app.route('/products')
@cross_origin(origin='*')
def get_products():
query = request.args.get('q')
# endpoint = endpoint_search.format(query)
endpoint = endpoint_search
res = requests.get(endpoint)
if res.status_code == 200:
json_search = res.json()
return json_search
else:
pass
if __name__ == '__main__':
app.run(debug=True, host='0.0.0.0', threaded=True)
But the server stays in idle until reach timeout. Why this is happening?
python flask request
python flask request
edited Nov 21 at 18:53
eyllanesc
68.6k93052
68.6k93052
asked Nov 21 at 17:33
olegario
147220
147220
You are not returning anything in theelse
block. So ifres.status_code == 201
, then you don't actually do anything. You need to have a response for ALL branches of anif-else
.
– Jabari Dash
Nov 21 at 17:35
@JabariDash the problem is that the request is never being triggered.
– olegario
Nov 21 at 17:48
add a comment |
You are not returning anything in theelse
block. So ifres.status_code == 201
, then you don't actually do anything. You need to have a response for ALL branches of anif-else
.
– Jabari Dash
Nov 21 at 17:35
@JabariDash the problem is that the request is never being triggered.
– olegario
Nov 21 at 17:48
You are not returning anything in the
else
block. So if res.status_code == 201
, then you don't actually do anything. You need to have a response for ALL branches of an if-else
.– Jabari Dash
Nov 21 at 17:35
You are not returning anything in the
else
block. So if res.status_code == 201
, then you don't actually do anything. You need to have a response for ALL branches of an if-else
.– Jabari Dash
Nov 21 at 17:35
@JabariDash the problem is that the request is never being triggered.
– olegario
Nov 21 at 17:48
@JabariDash the problem is that the request is never being triggered.
– olegario
Nov 21 at 17:48
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53417684%2frequest-not-being-executed%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
You are not returning anything in the
else
block. So ifres.status_code == 201
, then you don't actually do anything. You need to have a response for ALL branches of anif-else
.– Jabari Dash
Nov 21 at 17:35
@JabariDash the problem is that the request is never being triggered.
– olegario
Nov 21 at 17:48