forked from bhoomeendra/Normalization
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
40 lines (28 loc) · 1.08 KB
/
main.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
import ast
import json
from NormalForm.BCNF import BCNFDecompostion
from NormalForm.ThreeNF import ThreeNFDecompostion
from NormalForm.TwoNF import decompose2NF
from Helper import DataPaser, jsonParser
from flask import Flask,request,jsonify
from flask_cors import CORS
import jsonpickle
#attr = {"A", "B", "C", "D", "E"}
#fds = [[{"A", "B"}, {"D"}],[{"C"}, {"E"}]]
from Table import Table
app = Flask(__name__)
cors = CORS(app)
@app.route('/Decompose',methods=['POST'])
def DecomposeTable():
table = DataPaser(request.data.decode("utf-8"))
Dtablesin2NF = decompose2NF(Table(table.getAttr(),table.getFdsSet(),"1NF",-1,0))
Dtablesin3NF = ThreeNFDecompostion(Table(table.getAttr(),table.getFdsSet(),"1NF",-1,0))
DtablesinBcNF = BCNFDecompostion(Table(table.getAttr(),table.getFdsSet(),"1NF",-1,0))
DecomposeTables = DtablesinBcNF
#Will need to Write a custom parser
response = jsonParser(DecomposeTables)
as_dicts = [ast.literal_eval(x) for x in response]
as_json = json.dumps(as_dicts)
return as_json
if(__name__ == "__main__"):
app.run(debug=False)