forked from lhzhangLyon/isChannel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
36 lines (26 loc) · 749 Bytes
/
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
from flask import Flask
from flask import request
from detector.window import Window
app = Flask(__name__)
@app.route('/')
def hello_world():
return 'Hello World!'
@app.route('/data', methods=['POST'])
def data():
f = request.files['data']
return f.filename
@app.route('/list', methods=['POST'])
def find_list():
f = request.files['data']
url = request.form.get("url")
page_src = f.read()
data = []
if url is None:
return {'code': 1, 'msg': 'url is None', 'data': data}
try:
data = Window.run(url, page_src)
except Exception as e:
return {'code': 1, 'msg': str(e), 'data': data}
return {'code': 0, 'msg': 'success', 'data': data}
if __name__ == '__main__':
app.run()