@@ -134,23 +134,32 @@ def grecaptcha_verify(request): #This function is used to verify the google reca
@app.route('/',methods=['GET'])
defhome_get():
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
returnrender_template('home.html',builddate=builddate,version=version,domain=domain_prepared,recaptchaPublicKey=recaptchaPublicKey,showDomainSelect=showDomainSelect,loginbar=loginbar)#return the default site to create a new shorten link
@app.route('/',methods=['POST'])#This function is used to create a new url
defhome_post():
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,showDomainSelect=showDomainSelect)#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,loginbar=loginbar)#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
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,loginbar=loginbar)#return the user the prefilled form with an error message, because no url to short was provided
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,showDomainSelect=showDomainSelect)#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,loginbar=loginbar)#return the user the prefilled form with an error message, because no short link was provided
'INSERT INTO WEB_URL (LONG_URL, SHORT_URL, USERNAME) VALUES (?, ?, ?)',
[url,shorturl,userID]
)
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),loginbar=loginbar)#return the shorten link to the user
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')],showDomainSelect=showDomainSelect)#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,loginbar=loginbar)#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