-
-
Save kuyagic/21568a645183c6b67031bf27019b5225 to your computer and use it in GitHub Desktop.
Simple stream file proxy with Flask and Requests
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
from flask import Flask | |
from flask import Response | |
from flask import stream_with_context | |
import requests | |
app = Flask(__name__) | |
@app.route('/<path:url>') | |
def home(url): | |
req = requests.get(url, stream = True) | |
return Response(stream_with_context(req.iter_content()), content_type = req.headers['content-type']) | |
if __name__ == '__main__': | |
app.run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment