diff --git a/__main__.py b/__main__.py new file mode 100644 index 0000000000000000000000000000000000000000..1f9e8ce5a5b9d6b54667d513cc4f0784a8d77c33 --- /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 ecf5e2c903c303325b199348f82698ff17d9bab5..6c35d317cfbb15d46e58ccd7809c474b53c135d4 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