#!/usr/bin/python3 
from flask import Flask, request, Response, redirect
import requests

application = Flask(__name__)

@application.route('/', methods=["GET"])
def redirect_handler():
    redir = request.args.get("r", "")
    #print(redir)
    #res = requests.get(redir)
    #print(res.text)
    #res = requests.get("http://example.com")
    #return Response(res.text, status=200, mimetype='text/plain')
    #if redir.startswith("http://") or redir.startswith("https://"):
    #    return Response(redir, mimetype='text/plain')
    #return Response("Invalid URL", status=400, mimetype='text/plain')
    return Response("Invalid URL\r\n", status=200, mimetype='text/plain')

if __name__ == '__main__':
    application.run(debug=True)
