import subprocess
import sys,validators, base64
from flask import Flask
from flask import Response
import urlparse
def get_domain(url):
base_url = urlparse.urljoin(url, '/')
base_url = base_url[(base_url.index('://')+3):-1]
if base_url[:4] == "www.":
base_url = base_url[4:]
return base_url
app = Flask(__name__)
@app.route("/<url>", methods=['GET'])
def index(url):
url = base64.b64decode(url)
if url.find("http") < 0:
url = "http://" + url
if validators.url(url) == True:
print("Valid")
else:
# Check valid adress, do error heandler
url = "https://ya.ru"
domain = get_domain(url)
print(url)
print(domain)
if __name__ == "__main__":
app.run(host='0.0.0.0', port=8888)