Skip to content
Snippets Groups Projects
Commit 8d38d0c5 authored by Jonas Leder's avatar Jonas Leder
Browse files

add __main__.py, only production!!!

parent 2c610937
Branches
Tags
No related merge requests found
from main import startup, app
if(__name__ == "__main__"):
startup(True)
\ No newline at end of file
...@@ -22,8 +22,6 @@ from userprofile import userProfile #This script handles the overview of the own ...@@ -22,8 +22,6 @@ from userprofile import userProfile #This script handles the overview of the own
from deletelink import deleteLink #Script to delete Links of Users, if they want. from deletelink import deleteLink #Script to delete Links of Users, if they want.
from api import apiGet,apiPost #Scripts to handle the API from api import apiGet,apiPost #Scripts to handle the API
app = Flask(__name__)
domain_to_index = {} domain_to_index = {}
try: try:
...@@ -128,6 +126,10 @@ else: ...@@ -128,6 +126,10 @@ else:
domain_prepared = domain[0] domain_prepared = domain[0]
app = Flask(__name__)
@app.route('/', methods=['GET']) @app.route('/', methods=['GET'])
def home_get(): def home_get():
return home(request, builddate, version, domain_prepared, recaptchaPublicKey, showDomainSelect, cookieNotice, domain_to_index, s, loginEnabled) return home(request, builddate, version, domain_prepared, recaptchaPublicKey, showDomainSelect, cookieNotice, domain_to_index, s, loginEnabled)
...@@ -196,7 +198,7 @@ def apiDocs(): ...@@ -196,7 +198,7 @@ def apiDocs():
return apiGet(request, url_scheme, s, sAPI) return apiGet(request, url_scheme, s, sAPI)
def startup(): def startup(production):
table_check()# This code checks whether database table is created or not table_check()# This code checks whether database table is created or not
versionServer = get("https://gitlab.jonasled.de/jonasled/url_shorter_docker/raw/master/VERSION").text versionServer = get("https://gitlab.jonasled.de/jonasled/url_shorter_docker/raw/master/VERSION").text
if(open("VERSION", "r").read() != versionServer): print("Different version on the server found. Your version: " + open("VERSION", "r").read() + ", server version: " + versionServer + ".") if(open("VERSION", "r").read() != versionServer): print("Different version on the server found. Your version: " + open("VERSION", "r").read() + ", server version: " + versionServer + ".")
...@@ -206,4 +208,6 @@ def startup(): ...@@ -206,4 +208,6 @@ def startup():
else: 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. 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() #Only run the startup script, if this file is directly called. return app
\ No newline at end of file
if (__name__ == "__main__"): startup(production) #Only run the startup script, if this file is directly called.
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment