Update server.py

pull/1/head
Aidaho12 2018-01-15 13:56:04 +06:00 committed by GitHub
parent f26c798cad
commit b2e541007b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 3 deletions

View File

@ -1,11 +1,20 @@
#!/usr/bin/env python3
import os, sys
import configparser
path_config = "/home/ploginov/haproxy/haproxy-webintarface.config"
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')
from http.server import HTTPServer, CGIHTTPRequestHandler
sys.stderr = open('/opt/haproxy/log/haproxy-monitor.log', 'w')
webdir = "/opt/haproxy"
sys.stderr = open(log_path + '/opt/haproxy/log/haproxy-monitor.log', 'w')
webdir = fullpath
os.chdir(webdir)
server_address = ("", 8000)
server_address = (server_bind_ip, server_port)
httpd = HTTPServer(server_address, CGIHTTPRequestHandler)
httpd.serve_forever()