-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathserver_original.py
36 lines (31 loc) · 962 Bytes
/
server_original.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
from flask import Flask, request, jsonify
import json
import os
from query import *
import query_original
import time
app = Flask(__name__)
@app.route('/maniarest')
def call():
id1 = request.args.get('id1')
id2 = request.args.get('id2')
# print id1, id2
# os.system('./program {} {}'.format(id1, id2))
# ans = []
# with open('test.out', 'r') as f:
# for line in f:
# ans.append([_ for _ in map(int, line.split())])
# now = time.time()
# import profile
# profile.run('query(int({}), int({}))'.format(id1, id2))
# ans = query(int(id1), int(id2))
# print 'Answer Number = ', len(ans)
# print "time: {}".format(time.time() - now)
now = time.time()
ans = query_original.query(int(id1), int(id2))
print 'Answer Number = ', len(ans)
print 'time: {}'.format(time.time() - now)
return json.dumps(ans)
if __name__ == "__main__":
#app.debug = True
app.run(host = '0.0.0.0', port=80)