-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
executable file
·61 lines (47 loc) · 1.51 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
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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import print_function
import sys, time, os, re
from flask import Flask, render_template, request, jsonify
from xlrd import open_workbook
state = [0]
pylist_data = []
def get_master():
if state[0] == 0:
book = open_workbook('DB' + os.path.sep + 'masterobat.xls')
s = book.sheet_by_index(0)
for row in range(s.nrows):
if s.cell(row,0).value == '' or s.cell(row,0).value[0].isalpha() or s.cell(row,0).value[0] == ' ':
continue
else:
pylist_data.append([s.cell(row,0).value, s.cell(row,1).value, s.cell(row,2).value, s.cell(row,3).value])
state.pop()
state.append(1)
return pylist_data
else:
return pylist_data
def get_master_kw(token):
result = []
for i in get_master():
if re.match('.*{}.*'.format(token.upper()), i[1]):
result.append(i)
else:
pass
return result
searchkw = []
app = Flask(__name__)
@app.route("/")
def hello():
return render_template('index.html')
@app.route("/queryreq", methods=['GET'])
def queryreq():
if request.method == 'GET':
searchkw.append(request.args.get('key',''))
try:
return jsonify(result = get_master_kw(searchkw[0]))
finally:
searchkw.pop()
if __name__ == "__main__":
print('oh hello')
sys.stdout.flush()
app.run(host='0.0.0.0', port=5000, debug=False)