Install the requests
module (much nicer than using urllib2
) and then define a route which makes the necessary request – something like:
import requests
from flask import Flask
app = Flask(__name__)
@app.route('/some-url')
def get_data():
return requests.get('http://example.com').content
Depending on your set up though, it’d be better to configure your webserver to reverse proxy to the target site under a certain URL.