def startWebServer():
host = "discover" if not( settings.exists( "web" ) ) else settings.get( "web" )[ "host" ]
#cherrypy.server.socket_host = host if host != "discover" else get_ip_address() # use machine IP address if host = "discover"
cherrypy.server.socket_port = 80 if not( settings.exists( "web" ) ) else settings.get( "web" )[ "port" ]
log( LOG_LEVEL_STATE, CHILD_DEVICE_WEBSERVER, MSG_SUBTYPE_TEXT, "Starting on " + cherrypy.server.socket_host + ":" + str( cherrypy.server.socket_port ) )
conf = {
'/': {
'tools.staticdir.root': os.path.abspath( os.getcwd() ),
'tools.staticfile.root': os.path.abspath( os.getcwd() )
},
'/css': {
'tools.staticdir.on': True,
'tools.staticdir.dir': './web/css'
},
'/javascript': {
'tools.staticdir.on': True,
'tools.staticdir.dir': './web/javascript'
},
'/images': {
'tools.staticdir.on': True,
'tools.staticdir.dir': './web/images'
},
'/schedule.json': {
'tools.staticfile.on': True,
'tools.staticfile.filename': './thermostat_schedule.json'
},
'/favicon.ico': {
'tools.staticfile.on': True,
'tools.staticfile.filename': './web/images/favicon.ico'
},
'/graph': {
'tools.staticdir.on': True,
'tools.staticdir.dir': './web/graph'
}
}
cherrypy.config.update(
{ 'log.screen': debug,
'log.access_file': "",
'log.error_file': "",
'server.thread_pool' : 10
}
)
cherrypy.quickstart ( WebInterface(), '/', conf )
##############################################################################
# #
# Main #
# #
##############################################################################
评论列表
文章目录