diff --git a/api.py b/api.py index 96648ca8f12f4c9ab9f5d48a774bca1c202b4ab0..bf535ec2107456348f15df0ded1e3843b3d3d197 100644 --- a/api.py +++ b/api.py @@ -75,4 +75,8 @@ def apiPost(request, url_scheme, domain, sAPI): return jsonify( status="4", message="short url already in use" - ) \ No newline at end of file + ) + +if (__name__ == "__main__"): + print("This file is not made fore direct call, please run the main.py") + exit() \ No newline at end of file diff --git a/deletelink.py b/deletelink.py index 454a4ff653a2ff444138144b1edc82d39c1348b3..2d8a04bc19cf1432c8bbec87624e7c1e16bc6289 100644 --- a/deletelink.py +++ b/deletelink.py @@ -16,4 +16,8 @@ def deleteLink(request, s): cursor.execute('DELETE FROM WEB_URL WHERE SHORT_URL=? AND USERNAME=?', [linkToDelete, userID]) #Delete the entrie return redirect('/user/links') #redirect the user back to the table. except: - abort(500) \ No newline at end of file + abort(500) + +if (__name__ == "__main__"): + print("This file is not made fore direct call, please run the main.py") + exit() \ No newline at end of file diff --git a/githubcallback.py b/githubcallback.py index 8c18adeaaab1ed21e5b8c5a26c8442f9a2a12760..d23162f7867ba461f74f312e3739209132469419 100644 --- a/githubcallback.py +++ b/githubcallback.py @@ -19,4 +19,8 @@ def githubCallback(request, GITHUB_CLIENT_SECRET, GITHUB_CLIENT_ID, s): resp.set_cookie('username', s.dumps(username)) return resp except: - print("Authentication failed") \ No newline at end of file + print("Authentication failed") + +if (__name__ == "__main__"): + print("This file is not made fore direct call, please run the main.py") + exit() \ No newline at end of file diff --git a/googlecallback.py b/googlecallback.py index 0af7947865defebd958f203e89f8ec01fe2c52e3..f100d4847628b5fae43c09795bee7f0767676a53 100644 --- a/googlecallback.py +++ b/googlecallback.py @@ -17,4 +17,8 @@ def googleCallback(request, GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRET, url_scheme, resp.set_cookie('username', s.dumps(name)) return resp except: - print("Authentication failed") \ No newline at end of file + print("Authentication failed") + +if (__name__ == "__main__"): + print("This file is not made fore direct call, please run the main.py") + exit() \ No newline at end of file diff --git a/grecaptcha_verify.py b/grecaptcha_verify.py index 55acc158a056c59de1043d633a6cf279fc4ea969..4895296144ae5d97041614c2fc9ba0daf5264e49 100644 --- a/grecaptcha_verify.py +++ b/grecaptcha_verify.py @@ -9,4 +9,8 @@ def grecaptcha_verify(request, skipCaptcha, recaptchaPrivateKey): #This function verify_rs = post(url,params, headers=headers) #Send a post request with the parameters from before to googlde verify_rs = verify_rs.json() response = verify_rs.get("success", False) #Verify that the response includes the success, if so return True, if not return False - return response \ No newline at end of file + return response + +if (__name__ == "__main__"): + print("This file is not made fore direct call, please run the main.py") + exit() \ No newline at end of file diff --git a/home.py b/home.py index 3749ec1f6874c90ba9c0206257c62fb7be3af079..2e815ca9aa37695a39ce897b6ee012ebabbdc827 100644 --- a/home.py +++ b/home.py @@ -8,4 +8,8 @@ def home(request, builddate, version, domain_prepared, recaptchaPublicKey, showD try: return render_template('home.html', builddate=builddate, version=version, domain=domain_prepared, recaptchaPublicKey=recaptchaPublicKey, showDomainSelect=showDomainSelect, loginbar=loginbar, cookieNotice=cookieNotice ,domain_prefilled=domain_to_index[request.headers["host"]], loginEnabled=loginEnabled) #return the default site to create a new shorten link except: - abort(500) \ No newline at end of file + abort(500) + +if (__name__ == "__main__"): + print("This file is not made fore direct call, please run the main.py") + exit() \ No newline at end of file diff --git a/login.py b/login.py index 299dbe62155e7ee9dbf33044bd6223c2ffec3db3..30cd7e6e983278d13f30ae65bdad12f342396fac 100644 --- a/login.py +++ b/login.py @@ -4,4 +4,8 @@ def login(request, GITHUB_CLIENT_ID, cookieNotice, GOOGLE_CLIENT_ID, url_scheme, service = request.args.get("service") if(service == "github"): return redirect("https://github.com/login/oauth/authorize/?client_id=" + GITHUB_CLIENT_ID + "&scope=user") #redirect the user to the github login page and ask for access to user data (name, email, ...) if(service == "google"): return redirect("https://accounts.google.com/o/oauth2/v2/auth?client_id=" + GOOGLE_CLIENT_ID + "&scope=profile%20email%20openid&response_type=code&access_type=offline&include_granted_scopes=true&redirect_uri=" + url_scheme + "://" + domain[0] + "/user/google-callback") - return render_template("login.html", cookieNotice=cookieNotice) \ No newline at end of file + return render_template("login.html", cookieNotice=cookieNotice) + +if (__name__ == "__main__"): + print("This file is not made fore direct call, please run the main.py") + exit() \ No newline at end of file diff --git a/main.py b/main.py index 80a84e6e184346b1cdcc1d080ccd888d5ae51178..8f0849bb2a92c59b66bbabc62fb238591b1f43be 100644 --- a/main.py +++ b/main.py @@ -202,4 +202,4 @@ def startup(): else: app.run(host=host, port=5000, debug=True) #Start the Webserver in Debug mode. This means, if the script runs in an error, it will show the error message in Browser. -if (__name__ == "__main__"): startup() \ No newline at end of file +if (__name__ == "__main__"): startup() #Only run the startup script, if this file is directly called. \ No newline at end of file diff --git a/makeqr.py b/makeqr.py index 058324c707b2b4346e785e6898c685fe270c460f..f3c0d222670a8a42dede6300afa585aa8b0ab043 100644 --- a/makeqr.py +++ b/makeqr.py @@ -16,4 +16,8 @@ def makeQR(text): #This function is used to create a QR code and encode it base6 img = qr.make_image(fill_color="black", back_color="white") #Encode the WR as base 64 with BytesIO() as buffer: img.save(buffer, 'jpeg') - return b64encode(buffer.getvalue()).decode() \ No newline at end of file + return b64encode(buffer.getvalue()).decode() + +if (__name__ == "__main__"): + print("This file is not made fore direct call, please run the main.py") + exit() \ No newline at end of file diff --git a/newurl.py b/newurl.py index 8ae819510581bf68610635a88ab934a6379b7657..dd8ebdbe5f8b5326bd2deddcd24ab538aff756a7 100644 --- a/newurl.py +++ b/newurl.py @@ -39,3 +39,7 @@ def newurl(request, skipCaptcha, recaptchaPrivateKey, recaptchaPublicKey, buildd return render_template('home.html', short_url=shorturl, recaptchaPublicKey=recaptchaPublicKey, builddate=builddate, version=version, domain=domain_prepared, qrcode=makeQR(url_scheme + "://" + shorturl), loginbar=loginbar, cookieNotice=cookieNotice) #return the shorten link to the user else: return render_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, cookieNotice=cookieNotice) #return the user the prefilled form with an error message, because the url was already used + +if (__name__ == "__main__"): + print("This file is not made fore direct call, please run the main.py") + exit() \ No newline at end of file diff --git a/redirectShortenURL.py b/redirectShortenURL.py index ddf99da09a7d5b4443609f70ec12042443ebbeaa..bc723951d151ef92ff8b9431c14b65976b8aace3 100644 --- a/redirectShortenURL.py +++ b/redirectShortenURL.py @@ -29,3 +29,7 @@ def redirectShortenURL(request, short_url): return redirect(url) #I use temp redirect here, because the owner of a link can delete it. If then the link is reused, the user will maybe redirected to the wrong page else: abort(404) #Serve de default not found page. + +if (__name__ == "__main__"): + print("This file is not made fore direct call, please run the main.py") + exit() \ No newline at end of file diff --git a/table_check.py b/table_check.py index 329f34f4b5199ac77500182a4781e375b05fcc19..0f97a72a352df8ec6124ffcca12e2f84c57c6e84 100644 --- a/table_check.py +++ b/table_check.py @@ -23,4 +23,8 @@ def table_check(): #This function is used on start to make a new Database if not try: #Try making the database structure, if fails Database was already created. cursor.execute(create_table_analytics) except OperationalError: - pass \ No newline at end of file + pass + +if (__name__ == "__main__"): + print("This file is not made fore direct call, please run the main.py") + exit() \ No newline at end of file diff --git a/userprofile.py b/userprofile.py index bb50b994879460858edafa32b18adf6d7f4f9dd6..1ca308b03f94147b6dfbfd789082dcd3dc0cc096 100644 --- a/userprofile.py +++ b/userprofile.py @@ -41,3 +41,7 @@ def userProfile(request, cookieNotice, s, pageNumber, url_scheme): print(Exception) abort(500) #Shouldn't happen, 500 means internal server error return render_template('editEntries.html', content=response, loginbar=loginbar, cookieNotice=cookieNotice, backButton=backButton, nextButton=nextButton) #Put the table and the login div inside the template and server it to the user + +if (__name__ == "__main__"): + print("This file is not made fore direct call, please run the main.py") + exit() \ No newline at end of file