From eaba29fc6fb700a7fdc6483b8c79621cc7770996 Mon Sep 17 00:00:00 2001 From: Joakim Persson Date: Tue, 23 Jul 2024 14:23:42 +0200 Subject: [PATCH] =?UTF-8?q?L=C3=B6st=20problem=20med=20cirkul=C3=A4r=20imp?= =?UTF-8?q?ort.=20Tagit=20bort=20utkommenterad=20kod.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- smartassist/src/backend.py | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/smartassist/src/backend.py b/smartassist/src/backend.py index 7f78db0..e29d957 100644 --- a/smartassist/src/backend.py +++ b/smartassist/src/backend.py @@ -6,16 +6,13 @@ from flask_cors import CORS, cross_origin # CORS stands for Cross-Origin Resourc import requests import json import logging -import utils -from utils import set_local_logger, run_flask +from utils import set_local_logger -global log_level # Global variable to store the log level that is set in startservices.py logger = logging.getLogger(__name__) # Separate logger for this module -set_local_logger(logger) # Set log level for logger based on log_level +set_local_logger(logger) # Set log level for logger # Initialize a Flask application app = Flask(__name__) -# CORS(app, resources={r"/api/chat": {"origins": "*", "headers": ["Origin", "Content-Type", "Authorization"]}}) # Allow requests from any origin CORS(app, resources={ r"/api/chat": { "origins": "*", @@ -89,20 +86,20 @@ def get_response(user_query): # Return the generated response return response -# def run_flask(fport=5005): -# """ -# Starts the Flask server -# """ -# # Flask endpoint for user interaction -# logger.debug("Entering run_flask()") -# # app.run(port = str(str(fport)), debug=False) -# app.run(port = str(str(fport)), debug=True) -# # app.run(port=5000, debug=True, use_reloader=False) -# logger.debug("Exiting run_flask()") +def run_flask(fport=5005): + """ + Starts the Flask server + """ + # Flask endpoint for user interaction + logger.debug("Entering run_flask()") + # app.run(port = str(str(fport)), debug=False) + app.run(port = str(str(fport)), debug=True) + # app.run(port=5000, debug=True, use_reloader=False) + logger.debug("Exiting run_flask()") if __name__ == '__main__': # Run the Flask application - run_flask(app) + run_flask()