From 8d38d0c5afa85fc25a32836a515dcb3734e35f04 Mon Sep 17 00:00:00 2001 From: jonasled <jonas@jonasled.de> Date: Mon, 24 Feb 2020 17:13:22 +0100 Subject: [PATCH] add __main__.py, only production!!! --- __main__.py | 4 ++++ main.py | 12 ++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) create mode 100644 __main__.py diff --git a/__main__.py b/__main__.py new file mode 100644 index 0000000..1f9e8ce --- /dev/null +++ b/__main__.py @@ -0,0 +1,4 @@ +from main import startup, app + +if(__name__ == "__main__"): + startup(True) \ No newline at end of file diff --git a/main.py b/main.py index ecf5e2c..6c35d31 100644 --- a/main.py +++ b/main.py @@ -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 api import apiGet,apiPost #Scripts to handle the API -app = Flask(__name__) - domain_to_index = {} try: @@ -128,6 +126,10 @@ else: domain_prepared = domain[0] + + +app = Flask(__name__) + @app.route('/', methods=['GET']) def home_get(): return home(request, builddate, version, domain_prepared, recaptchaPublicKey, showDomainSelect, cookieNotice, domain_to_index, s, loginEnabled) @@ -196,7 +198,7 @@ def apiDocs(): return apiGet(request, url_scheme, s, sAPI) -def startup(): +def startup(production): 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 if(open("VERSION", "r").read() != versionServer): print("Different version on the server found. Your version: " + open("VERSION", "r").read() + ", server version: " + versionServer + ".") @@ -205,5 +207,7 @@ def startup(): serve(app, host=host, port= 5000, url_scheme=url_scheme) #Start the production Webserver for all users on port 5000 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. + + return app -if (__name__ == "__main__"): startup() #Only run the startup script, if this file is directly called. \ 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 -- GitLab