-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.py
73 lines (61 loc) · 1.99 KB
/
server.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
from flask import Flask, request, jsonify
from flask_cors import CORS
import json
from requests import post
from flask_api import status
import pandas as pd
# from mysql import mysql_connection
from ETL_pipeline import ETL
app = Flask('__name__')
CORS(app)
@app.route('/file', methods=['POST'])
def upload_file():
if request.method == 'POST':
file = request.files['file']
etl = ETL()
etl.analysis_module(file)
return 'success', status.HTTP_200_OK
@app.route('/numerics', methods=['GET'])
def analysis():
# import the module
etl = ETL()
splits = etl.countQueries()
create,read,update,delete,miscell = splits[3],splits[1],splits[0],splits[2],splits[4]
numeric = [len(create),len(read),len(update),len(delete),len(miscell)]
return {'numeric': numeric}
@app.route('/time', methods=['GET'])
def time():
etl=ETL()
count = etl.predict()
return {'count':count}
@app.route('/api', methods=['GET'])
def api():
# import the module
etl = ETL()
query = etl.getQueriesSQL()
return {'api':"success"}
@app.route('/connection', methods=['POST'])
def connection():
if request.method == 'POST':
info = json.loads(request.data)
username = info.get('username')
password = info.get('password')
database = info.get('database')
host_url = info.get('host_url')
query_name = info.get('query_name')
query_info = info.get('query_info')
port=info.get('port')
etl=ETL()
# etl.dfconcat()
output = etl.executeAPISQL(username,password,host_url,database,query_name,port,query_info)
return {"result": output}, status.HTTP_200_OK
else:
return status.HTTP_400_BAD_REQUEST
@app.route('/getapis', methods=['GET'])
def api_details():
# import the module
etl = ETL()
apis = etl.getAPIs()
return {'apis': apis}
if __name__ == '__main__':
app.run(host='0.0.0.0',debug=True)