timeout - Python requests return 504 in localhost -
i run werkzeug server (via flask) , trying connect localhost requests lib , got 504 error, if open http://127.0.0.1:5000/ in browser - ok.
my code:
import requests r = requests.get('http://127.0.0.1:5000/') print(r.content)
response error:
b'\r\n\r\nerror: gateway timeout\r\n
error: gateway timeout
\r\n\r\n\r\nwhile trying retrieve url http://127.0.0.1:5000/:
\r\n\r\n\r\n
- connection refused
your cache administrator webmaster.\r\n\r\ngenerated thu, 06 apr 2017 11:31:09 gmt 10.101.0.1 (mikrotik httpproxy)\r\n\r\n'
flask code:
from flask import flask, request, render_template, jsonify, response import geolocation import models import json bson.json_util import dumps bson import json_util app = flask(__name__) @app.route('/', methods=['get', 'post']) def index(): return 'ok' ....
how connect localhost (ip + port) via requests lib?
found solution, disable proxy
import os import requests os.environ['no_proxy'] = '127.0.0.1' r = requests.get('http://127.0.0.1:5000') print(r.content)
Comments
Post a Comment