-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
47 lines (35 loc) · 1.1 KB
/
app.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
from flask import Flask
from flask import jsonify
from flask import render_template
from flask_cors import CORS, cross_origin
import request_handler
from flask import request
app = Flask(__name__, static_folder="./client/dist", template_folder="./client")
CORS(app)
app.debug = True
@app.route('/', methods=['GET'])
def index_page():
return render_template('index.html')
@app.route('/data', methods = ['POST'])
def getData():
reqHandler = request_handler.RequestHandler()
#print(request.json)
data = request.json
result = reqHandler.main(data['info'])
return jsonify(result)
@app.route('/req_data/<id>', methods = ['GET'])
def getReqData(id):
import tool_db
inst = tool_db.ToolDB()
result = inst.getRequestData(id)
if result:
return jsonify(result)
return jsonify({'error':True})
@app.after_request
def after_request(response):
response.headers.add('Access-Control-Allow-Origin', '*')
response.headers.add('Access-Control-Allow-Headers', 'Content-Type,Authorization')
response.headers.add('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE')
return response
if __name__ == '__main__':
app.run()