Skip to content

Commit a4ab650

Browse files
committed
Flaskify server emulator.
1 parent 71ce110 commit a4ab650

File tree

3 files changed

+39
-0
lines changed

3 files changed

+39
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
*.pyc
12
/.bsp/
23
/.idea/
34

File renamed without changes.

python/server.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/usr/bin/python3
2+
3+
from flask import Flask, jsonify, request
4+
5+
from graphs import MyGraph
6+
7+
app = Flask(__name__)
8+
9+
graph = MyGraph()
10+
query_count = 0
11+
12+
@app.route('/select', methods=['POST'])
13+
def do_select():
14+
global graph
15+
global query_count
16+
query_count += 1
17+
rq = request.json
18+
name = rq['problemName']
19+
graph.generate(int(name))
20+
return jsonify({'problemName': name})
21+
22+
@app.route('/explore', methods=['POST'])
23+
def do_explore():
24+
global graph
25+
global query_count
26+
rq = request.json
27+
plans = rq['plans']
28+
results = []
29+
for plan in plans:
30+
gates = [int(g) for g in plan]
31+
labels = graph.explore(gates)
32+
results.append(labels)
33+
rs = {'results': results, 'queryCount': query_count}
34+
return jsonify(rs)
35+
36+
if __name__ == "__main__":
37+
app.run(debug=True)
38+

0 commit comments

Comments
 (0)