Fetch a file from a local url with Python requests?

后端 未结 6 1257
误落风尘
误落风尘 2020-12-02 14:29

I am using Python\'s requests library in one method of my application. The body of the method looks like this:

def handle_remote_file(url, **kwargs):
    res         


        
6条回答
  •  北荒
    北荒 (楼主)
    2020-12-02 15:09

    I think simple solution for this will be creating temporary http server using python and using it.

    1. Put all your files in temporary folder eg. tempFolder
    2. Go to that directory and create a temporary http server in terminal/cmd as per your OS using command python -m http.server 8000 (Note 8000 is port no.)
    3. This will you give you a link to http server. You can access it from http://127.0.0.1:8000/
    4. Open your desired file in browser and copy the link to your url.

提交回复
热议问题