Python requests 503 erros when trying to access localhost:8000

后端 未结 2 685
伪装坚强ぢ
伪装坚强ぢ 2021-01-28 05:25

I am facing a bit of a situation,

Scenario: I got a django rest api running on my localhost:8000 and I want to access the api using my command line. I have tried urllib

2条回答
  •  半阙折子戏
    2021-01-28 05:51

    I had a similar problem, but found that it was the company's proxy that was preventing from pinging myself.

    503 Reponse when trying to use python request on local website

    Try:

    >>> import requests
    >>> session = requests.Session()
    >>> session.trust_env = False
    >>> r = session.get("http://localhost:5000/")
    >>> r
    
    >>> r.content
    'Hello World!'
    

提交回复
热议问题