from flask import Flask, redirect, Response

app = Flask(__name__)
valid_locations = ['www.helion.pl', 'poprawny_adres']

@app.route('/redirect/<url>')
def redirect_url(url):
    sanitizedLocation = getSanitizedLocation(url) # Bezpieczny kod.
    print(sanitizedLocation)
    return redirect("http://" + sanitizedLocation, code = 302)

def getSanitizedLocation(location):
    if (location in valid_locations):
        return location
    else:
        return "Sprawdź adres URL"
    
if __name__ == ' __main__ ':
	app.run(debug = True)