-
Notifications
You must be signed in to change notification settings - Fork 52
/
web.py
53 lines (36 loc) · 1.25 KB
/
web.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
# encoding:utf-8
import os, subprocess
from multiprocessing import Process, Queue
from bottle import route, run, template, request
from conf import web_port, queue_num, callback_mail, wvs_save_dir
queue_waiting = Queue()
queue_scaning = Queue(queue_num)
@route('/compare', method='POST')
def compare_scaner():
urls = request.POST.url.split('\n')
for url in urls:
url = url.strip()
if url:
queue_waiting.put(url)
return {
"msg": 'Adding %d tasks' % len(urls),
"callback_mail": callback_mail
}
@route('/index', method='GET')
def index():
return template('index.html', scaning_count=queue_scaning.qsize(), waiting_count=queue_waiting.qsize())
@route('/expire', method='GET')
def expire():
queue_scaning.get()
return 'expire success!'
def queue_get(queue_waiting, queue_scaning):
while True:
url = queue_waiting.get()
queue_scaning.put(1)
print "Scaning: %s" % url
subprocess.Popen("python wvs.py -u \"%s\"" % url, shell=True)
if __name__ == '__main__':
if not os.path.exists(wvs_save_dir):
os.mkdir(wvs_save_dir)
Process(target=queue_get, args=(queue_waiting, queue_scaning)).start()
run(host='0.0.0.0', port=web_port)