51 lines
1.2 KiB
Python
Executable File
51 lines
1.2 KiB
Python
Executable File
#!/usr/bin/python3
|
|
import os
|
|
import cherrypy
|
|
import OpenSSL
|
|
import sys
|
|
|
|
PATH = os.path.abspath(os.path.dirname(__file__))
|
|
|
|
_SCRIPT_PATH = os.path.dirname(sys.argv[0])
|
|
sys.path.append(_SCRIPT_PATH)
|
|
|
|
import voltage
|
|
import weather
|
|
import dynamic
|
|
import status
|
|
|
|
server_config={
|
|
'server.socket_host': '0.0.0.0',
|
|
'server.socket_port':443,
|
|
'server.ssl_module':'builtin',
|
|
'server.ssl_certificate':'/home/www/.cert/fullchain1.pem',
|
|
'server.ssl_private_key':'/home/www/.cert/privkey1.pem'
|
|
}
|
|
cherrypy.config.update(server_config)
|
|
|
|
if __name__ == '__main__':
|
|
|
|
|
|
|
|
conf = {
|
|
'/': {
|
|
'tools.sessions.on': True,
|
|
'tools.staticdir.root': os.path.abspath(_SCRIPT_PATH + '/')
|
|
},
|
|
'/static': {
|
|
'tools.staticdir.on': True,
|
|
'tools.staticdir.dir': './static'
|
|
},
|
|
'/data': {
|
|
'tools.staticdir.on': False,
|
|
'tools.staticdir.dir': './dynamic'
|
|
}
|
|
}
|
|
|
|
cherrypy.tree.mount(voltage.EnergyInfo(), "/", conf)
|
|
cherrypy.tree.mount(weather.WeatherInfo(), "/weather", conf)
|
|
cherrypy.tree.mount(status.StatusInfo(), "/status", conf)
|
|
cherrypy.tree.mount(dynamic.DynamicData(), "/data", conf)
|
|
cherrypy.engine.start()
|
|
cherrypy.engine.block()
|