From 0080ebb597f0999c25e67be59c2d63f881b59a9b Mon Sep 17 00:00:00 2001 From: Jaydin_MacBook Date: Thu, 11 Jan 2024 18:48:44 -0500 Subject: [PATCH] Updated Flask Ports --- backend/app.py | 4 ++-- backend/config.py | 19 ++++++++++++++++--- frontend/app.py | 2 +- frontend/config.py | 21 ++++++++++++++++----- 4 files changed, 35 insertions(+), 11 deletions(-) diff --git a/backend/app.py b/backend/app.py index 6505001..3babe44 100644 --- a/backend/app.py +++ b/backend/app.py @@ -77,7 +77,7 @@ def authorize_drive(): if gauth.access_token_expired: gauth.Refresh() gauth.SaveCredentialsFile("credentials.json") - + drive = GoogleDrive(gauth) return drive @@ -297,4 +297,4 @@ def list_root_directory(): scheduler.init_app(app) scheduler.start() - app.run(host='0.0.0.0', debug=app.config['DEBUG']) + app.run(host='0.0.0.0', port=app.config['PORT'], debug=app.config['DEBUG']) diff --git a/backend/config.py b/backend/config.py index 263290b..c1dde59 100644 --- a/backend/config.py +++ b/backend/config.py @@ -1,5 +1,18 @@ # config.py -from selenium.webdriver.chrome.options import Options - +import os +from dotenv import load_dotenv +import sys # Flask configuration -DEBUG = True # Set to False in production \ No newline at end of file +load_dotenv() + +env = os.environ.get('ENVIRONMENT') + +if env == 'dev': + PORT = 5003 + DEBUG = True +elif env == 'prod': + PORT = 5001 + DEBUG = False +else: + print("Environment not specified. Please provide a valid environment.") + sys.exit(1) diff --git a/frontend/app.py b/frontend/app.py index d737119..9317831 100644 --- a/frontend/app.py +++ b/frontend/app.py @@ -35,4 +35,4 @@ def login(): return jsonify(success=True) if __name__ == '__main__': - app.run(host='0.0.0.0', debug=app.config['DEBUG']) + app.run(host='0.0.0.0', port=app.config['PORT'], debug=app.config['DEBUG']) diff --git a/frontend/config.py b/frontend/config.py index 4003ce1..de0cb9f 100644 --- a/frontend/config.py +++ b/frontend/config.py @@ -1,11 +1,22 @@ # config.py +import os +from dotenv import load_dotenv +import sys # Flask configuration -DEBUG = True # Set to False in production +load_dotenv() + +env = os.environ.get('ENVIRONMENT') + +if env == 'dev': + PORT = 5004 + DEBUG = True +elif env == 'prod': + PORT = 5002 + DEBUG = False +else: + print("Environment not specified. Please provide a valid environment.") + sys.exit(1) # CORS Configurations CORS_HEADERS = 'Content-Type' - -# Security configurations -# It's advisable to use environment variables for sensitive data -# Example: SECRET_KEY = os.environ.get('SECRET_KEY') or 'a-default-secret'