-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebui.py
More file actions
executable file
·46 lines (35 loc) · 1.42 KB
/
Copy pathwebui.py
File metadata and controls
executable file
·46 lines (35 loc) · 1.42 KB
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
#!/usr/bin/env python
import cherrypy
import xfipchk
class XforceForm(object):
def __init__(self, address='127.0.0.1', port=8000):
# parms override anything in config
cherrypy.config.update({'server.socket_port': port,
'server.socket_host': address})
@cherrypy.expose
def index(self):
return "/"
@cherrypy.expose()
@cherrypy.tools.json_out()
def process_form(self, api_key, api_password, ip_addresses):
if xfipchk.validate_api_creds(api_key.strip()) and xfipchk.validate_api_creds(api_password.strip()):
form_ips = []
if isinstance(ip_addresses, str):
form_ips = ip_addresses.splitlines()
good_ips = []
for i in form_ips:
if xfipchk.validate_ip(i):
good_ips.append(i)
return xfipchk.call_xforce_api(good_ips, api_key, api_password)
else:
return cherrypy.HTTPError("400: Bad Request", 400)
if __name__ == '__main__':
webapp = XforceForm('127.0.0.1', 8000)
cherrypy.tree.mount(webapp, config='./server.cfg')
if hasattr(cherrypy.engine, 'signal_handler'):
cherrypy.engine.signal_handler.subscribe()
# Initialize console control
if hasattr(cherrypy.engine, "console_control_handler"):
cherrypy.engine.console_control_handler.subscribe()
cherrypy.engine.start()
cherrypy.engine.block()