domain=os.environ["domains"].split(";")#Get the domains from the enviorement variable. If no enviorement variable is set set it to 127.0.0.1:5000 (for testing)
domain=os.environ["domains"].split(";")#Get the domains from the enviorement variable. If no enviorement variable is set set it to 127.0.0.1:5000 (for testing)
...
@@ -57,10 +58,13 @@ except:
...
@@ -57,10 +58,13 @@ except:
index=0
index=0
fordomainsindomain:#Make from every domnain a entry for the select box later
fordomainsindomain:#Make from every domnain a entry for the select box later
returnrender_template('home.html',builddate=builddate,version=version,domain=domain_prepared,recaptchaPublicKey=recaptchaPublicKey)#return the default site to create a new shorten link
returnrender_template('home.html',builddate=builddate,version=version,domain=domain_prepared,recaptchaPublicKey=recaptchaPublicKey,showDomainSelect=showDomainSelect)#return the default site to create a new shorten link
@app.route('/',methods=['POST'])#This function is used to create a new url
@app.route('/',methods=['POST'])#This function is used to create a new url
defhome_post():
defhome_post():
ifnotgrecaptcha_verify(request)andnotskipCaptcha:
ifnotgrecaptcha_verify(request)andnotskipCaptcha:
returnrender_template('home.html',builddate=builddate,version=version,domain=domain_prepared,snackbar="There was an error validating, that you are a human, please try again.",long_url_prefilled=request.form.get('url'),short_url_prefilled=request.form.get('short').lower(),domain_prefilled=domain_to_index[request.form.get('domain')],recaptchaPublicKey=recaptchaPublicKey)#return the user the prefilled form with an error message, because no url to short was provided
returnrender_template('home.html',builddate=builddate,version=version,domain=domain_prepared,snackbar="There was an error validating, that you are a human, please try again.",long_url_prefilled=request.form.get('url'),short_url_prefilled=request.form.get('short').lower(),domain_prefilled=domain_to_index[request.form.get('domain')],recaptchaPublicKey=recaptchaPublicKey,showDomainSelect=showDomainSelect)#return the user the prefilled form with an error message, because no url to short was provided
if (request.form.get('url').replace("","")==""):
if (request.form.get('url').replace("","")==""):
returnrender_template('home.html',builddate=builddate,version=version,domain=domain_prepared,snackbar="Please enter a url to short, before submitting this form",long_url_prefilled=request.form.get('url'),short_url_prefilled=request.form.get('short').lower(),domain_prefilled=domain_to_index[request.form.get('domain')],recaptchaPublicKey=recaptchaPublicKey)#return the user the prefilled form with an error message, because no url to short was provided
returnrender_template('home.html',builddate=builddate,version=version,domain=domain_prepared,snackbar="Please enter a url to short, before submitting this form",long_url_prefilled=request.form.get('url'),short_url_prefilled=request.form.get('short').lower(),domain_prefilled=domain_to_index[request.form.get('domain')],recaptchaPublicKey=recaptchaPublicKey,showDomainSelect=showDomainSelect)#return the user the prefilled form with an error message, because no url to short was provided
if (request.form.get('short').replace("","")==""):
if (request.form.get('short').replace("","")==""):
returnrender_template('home.html',builddate=builddate,version=version,domain=domain_prepared,snackbar="Please enter a short name, before submitting this form",long_url_prefilled=request.form.get('url'),short_url_prefilled=request.form.get('short').lower(),domain_prefilled=domain_to_index[request.form.get('domain')],recaptchaPublicKey=recaptchaPublicKey)#return the user the prefilled form with an error message, because no short link was provided
returnrender_template('home.html',builddate=builddate,version=version,domain=domain_prepared,snackbar="Please enter a short name, before submitting this form",long_url_prefilled=request.form.get('url'),short_url_prefilled=request.form.get('short').lower(),domain_prefilled=domain_to_index[request.form.get('domain')],recaptchaPublicKey=recaptchaPublicKey,showDomainSelect=showDomainSelect)#return the user the prefilled form with an error message, because no short link was provided
returnrender_template('home.html',short_url=shorturl,recaptchaPublicKey=recaptchaPublicKey,builddate=builddate,version=version,domain=domain_prepared,qrcode=makeQR("http://"+shorturl))#return the shorten link to the user
returnrender_template('home.html',short_url=shorturl,recaptchaPublicKey=recaptchaPublicKey,builddate=builddate,version=version,domain=domain_prepared,qrcode=makeQR("http://"+shorturl))#return the shorten link to the user
else:
else:
returnrender_template('home.html',builddate=builddate,version=version,recaptchaPublicKey=recaptchaPublicKey,domain=domain_prepared,snackbar="URL already used, please try another one",long_url_prefilled=request.form.get('url'),short_url_prefilled=request.form.get('short').lower(),domain_prefilled=domain_to_index[request.form.get('domain')])#return the user the prefilled form with an error message, because the url was already used
returnrender_template('home.html',builddate=builddate,version=version,recaptchaPublicKey=recaptchaPublicKey,domain=domain_prepared,snackbar="URL already used, please try another one",long_url_prefilled=request.form.get('url'),short_url_prefilled=request.form.get('short').lower(),domain_prefilled=domain_to_index[request.form.get('domain')],showDomainSelect=showDomainSelect)#return the user the prefilled form with an error message, because the url was already used
@app.route('/favicon.ico')#Redirect to the static url of the favicon
@app.route('/favicon.ico')#Redirect to the static url of the favicon