Cleanup
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
#!/usr/bin/python3
|
||||
"""Our cherrypy server, it all starts here
|
||||
"""
|
||||
import os
|
||||
import cherrypy
|
||||
import OpenSSL
|
||||
@@ -6,27 +8,37 @@ import sys
|
||||
|
||||
PATH = os.path.abspath(os.path.dirname(__file__))
|
||||
|
||||
# Where are we?
|
||||
_SCRIPT_PATH = os.path.dirname(sys.argv[0])
|
||||
# So we can load static libraries
|
||||
sys.path.append(_SCRIPT_PATH)
|
||||
# Certificates reside here
|
||||
_CERT_PATH = _SCRIPT_PATH + '/.cert'
|
||||
|
||||
import voltage
|
||||
"""Let's look at the statically linked stuff (i.e. the files that will
|
||||
serve us data). These imports are static files in the same directory. Each
|
||||
a spearate application with it's own face and behavior
|
||||
"""
|
||||
# UI for weather ./weather.py
|
||||
import weather
|
||||
# CSV "API" for graphs, or individual pulling ./dynamic.py
|
||||
import dynamic
|
||||
# UI for RasPi / davis status ./status.py
|
||||
import status
|
||||
|
||||
#basic config for the server, the SSL part is questionable...
|
||||
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'
|
||||
'server.socket_port': 443,
|
||||
'server.ssl_module': 'builtin',
|
||||
'server.ssl_certificate': _CERT_PATH + '/fullchain1.pem',
|
||||
'server.ssl_private_key': _CERT_PATH + '/privkey1.pem'
|
||||
}
|
||||
# commit the config settings
|
||||
cherrypy.config.update(server_config)
|
||||
|
||||
# If launched directly, let's go
|
||||
if __name__ == '__main__':
|
||||
|
||||
|
||||
|
||||
conf = {
|
||||
'/': {
|
||||
'tools.sessions.on': True,
|
||||
@@ -42,9 +54,11 @@ if __name__ == '__main__':
|
||||
}
|
||||
}
|
||||
|
||||
cherrypy.tree.mount(voltage.EnergyInfo(), "/", conf)
|
||||
cherrypy.tree.mount(weather.WeatherInfo(), "/weather", conf)
|
||||
# Here are the different served mounts
|
||||
cherrypy.tree.mount(weather.WeatherInfo(), "/", conf)
|
||||
cherrypy.tree.mount(status.StatusInfo(), "/status", conf)
|
||||
cherrypy.tree.mount(dynamic.DynamicData(), "/data", conf)
|
||||
|
||||
# Run the server, lock it in place.
|
||||
cherrypy.engine.start()
|
||||
cherrypy.engine.block()
|
||||
|
||||
Reference in New Issue
Block a user