thermostat.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:thermostat_ita 作者: jpnos26 项目源码 文件源码
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                                                                 #
#                                                                            #
##############################################################################
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号