|
@@ -1,36 +1,14 @@
|
|
|
-import logging
|
|
|
from flask import Flask, request
|
|
|
-from flask_cors import CORS
|
|
|
-import json
|
|
|
-import os.path
|
|
|
+import logging
|
|
|
import traceback
|
|
|
+import os.path
|
|
|
|
|
|
from engine.handle_request import handleOccGetQuery, handleGetContext
|
|
|
+from Config.config_loader import config
|
|
|
|
|
|
|
|
|
app = Flask(__name__)
|
|
|
-CORS(app)
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-customAppConfig = {
|
|
|
- 'dataConfig': {
|
|
|
- 'appath': app.root_path,
|
|
|
- 'dbpath': os.path.join(app.root_path, os.pardir) + '/db/first_db/',
|
|
|
- 'dbfile_default': 'test1.db',
|
|
|
- 'data_interface': 'sqlite3',
|
|
|
- 'listOcc': ["occ00001", "occ00002", "occ00003"]
|
|
|
- },
|
|
|
- 'loggerConfig': {
|
|
|
- 'filename': 'Progetto2023_BE.log',
|
|
|
- 'level': logging.INFO
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-logging.basicConfig(filename = customAppConfig['loggerConfig']['filename'], level=customAppConfig['loggerConfig']['level'])
|
|
|
-
|
|
|
-
|
|
|
+config(app)
|
|
|
|
|
|
|
|
|
|
|
@@ -49,7 +27,7 @@ def simpleQuery():
|
|
|
queryDTO = request.get_json()
|
|
|
queryList = queryDTO['queryList']
|
|
|
cooccorrenze = queryDTO.get('cooccorrenze')
|
|
|
- output = handleOccGetQuery(queryList, cooccorrenze, customAppConfig['dataConfig'])
|
|
|
+ output = handleOccGetQuery(queryList, cooccorrenze, app.config['DATA_CONFIG'])
|
|
|
|
|
|
|
|
|
|
|
@@ -76,7 +54,7 @@ def simpleContext():
|
|
|
listResults = queryDTO['listResults']
|
|
|
cooccorrenze = queryDTO['cooccorrenze']
|
|
|
|
|
|
- output = handleGetContext(queryList, listResults, cooccorrenze, customAppConfig['dataConfig'])
|
|
|
+ output = handleGetContext(queryList, listResults, cooccorrenze, app.config['dataConfig'])
|
|
|
|
|
|
return output, 200
|
|
|
|