haproxy-wi/server.py

21 lines
664 B
Python
Raw Normal View History

2018-01-15 06:10:16 +00:00
#!/usr/bin/env python3
import os, sys
2018-01-15 07:56:04 +00:00
import configparser
2018-01-15 07:59:31 +00:00
path_config = "/opt/haproxy/haproxy-webintarface.config"
2018-01-15 07:56:04 +00:00
config = configparser.ConfigParser()
config.read(path_config)
log_path = config.get('main', 'log_path')
fullpath = config.get('main', 'fullpath')
server_bind_ip = config.get('main', 'server_bind_ip')
server_port = config.getint('main', 'server_port')
2018-01-15 06:10:16 +00:00
from http.server import HTTPServer, CGIHTTPRequestHandler
2018-01-15 07:56:04 +00:00
sys.stderr = open(log_path + '/opt/haproxy/log/haproxy-monitor.log', 'w')
webdir = fullpath
2018-01-15 06:10:16 +00:00
os.chdir(webdir)
2018-01-15 07:56:04 +00:00
server_address = (server_bind_ip, server_port)
2018-01-15 06:10:16 +00:00
httpd = HTTPServer(server_address, CGIHTTPRequestHandler)
httpd.serve_forever()