rahgadda commited on
Commit
3024ca5
·
verified ·
1 Parent(s): ae0839f

Initial Draft

Browse files
lib/api/endpoints/MappingAPI.py ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from flask.views import MethodView
2
+ from flask import request,Response
3
+
4
+ import json
5
+ import traceback
6
+ import logging
7
+
8
+ import lib.api.vector.VectorStore as cv
9
+
10
+ class MappingAPI(MethodView):
11
+ lv_logger = logging.getLogger(__name__)
12
+
13
+ def get(self):
14
+ resp = { "test message": "working"}
15
+ status = 200
16
+ return Response(json.dumps(resp), status=status, mimetype='application/json')
17
+
18
+ def post(self):
19
+ try:
20
+ # Saving file
21
+ lv_file = request.files['file']
22
+ lv_source_domain = request.form['source_domain']
23
+ lv_saved_file_name = 'storage/' + lv_file.filename.split('/')[-1]
24
+ lv_file.save(lv_saved_file_name)
25
+
26
+ # Processing the file
27
+ lv_response = cv.fn_map_data(lv_saved_file_name,lv_file.filename.split('/')[-1],lv_source_domain)
28
+
29
+ status = 200
30
+ return Response(lv_response, status=status, mimetype='application/json')
31
+ except Exception as e:
32
+ self.lv_logger.error(e)
33
+ self.lv_logger.error(traceback.format_exc())
34
+ return Response(json.dumps({"error_message": str(e)}), status=500, mimetype='application/json')
35
+
lib/api/endpoints/VectorStoreAPI.py CHANGED
@@ -1,39 +1,39 @@
1
- from flask.views import MethodView
2
- from flask import request,Response
3
-
4
- import json
5
- import traceback
6
- import logging
7
-
8
- import lib.api.vector.VectorStore as cv
9
-
10
- class VectorStoreAPI(MethodView):
11
- lv_logger = logging.getLogger(__name__)
12
-
13
- def get(self):
14
- resp = { "test message": "working"}
15
- status = 200
16
- return Response(json.dumps(resp), status=status, mimetype='application/json')
17
-
18
- def post(self):
19
- try:
20
- # Saving file
21
- lv_file = request.files['file']
22
- lv_domain = request.form['domain']
23
- lv_file_name = 'storage/' + lv_domain + ".xlsx"
24
- lv_file.save(lv_file_name)
25
-
26
- # Processing the file
27
- lv_status = cv.fn_create_vector_store(lv_file_name, lv_domain)
28
-
29
- return Response(
30
- json.dumps({"status":lv_status}),
31
- status=200,
32
- mimetype='application/json'
33
- )
34
- except Exception as e:
35
- self.lv_logger.error(e)
36
- self.lv_logger.error(type(e))
37
- self.lv_logger.error(traceback.format_exc())
38
-
39
  return Response(json.dumps({"error_message":str(e)}), status=500, mimetype='application/json')
 
1
+ from flask.views import MethodView
2
+ from flask import request,Response
3
+
4
+ import json
5
+ import traceback
6
+ import logging
7
+
8
+ import lib.api.vector.VectorStore as cv
9
+
10
+ class VectorStoreAPI(MethodView):
11
+ lv_logger = logging.getLogger(__name__)
12
+
13
+ def get(self):
14
+ resp = { "test message": "working"}
15
+ status = 200
16
+ return Response(json.dumps(resp), status=status, mimetype='application/json')
17
+
18
+ def post(self):
19
+ try:
20
+ # Saving file
21
+ lv_file = request.files['file']
22
+ lv_domain = request.form['domain']
23
+ lv_file_name = 'storage/' + lv_domain + ".xlsx"
24
+ lv_file.save(lv_file_name)
25
+
26
+ # Processing the file
27
+ lv_status = cv.fn_create_vector_store(lv_file_name, lv_domain)
28
+
29
+ return Response(
30
+ json.dumps({"status":lv_status}),
31
+ status=200,
32
+ mimetype='application/json'
33
+ )
34
+ except Exception as e:
35
+ self.lv_logger.error(e)
36
+ self.lv_logger.error(type(e))
37
+ self.lv_logger.error(traceback.format_exc())
38
+
39
  return Response(json.dumps({"error_message":str(e)}), status=500, mimetype='application/json')