Example #1
0
def runMainApp():
    #set up the config
    conf = {
        '/': {
            'tools.staticdir.root': os.getcwd(),
            'tools.encode.on': True,
            'tools.encode.encoding': 'utf-8',
            'tools.sessions.on': True,
            'tools.sessions.timeout':
            60 * 1,  #timeout is in minutes, * 60 to get hours

            # The default session backend is in RAM. Other options are 'file',
            # 'postgres', 'memcached'. For example, uncomment:
            # 'tools.sessions.storage_type': 'file',
            # 'tools.sessions.storage_path': '/tmp/mysessions',
        },

        #configuration for the static assets directory
        '/static': {
            'tools.staticdir.on': True,
            'tools.staticdir.dir': 'static',
        },
        '/css': {
            'tools.staticdir.on': True,
            'tools.staticdir.dir': 'static',
        },

        #once a favicon is set up, the following code could be used to select it for cherrypy
        #'/favicon.ico': {
        #    'tools.staticfile.on': True,
        #    'tools.staticfile.filename': os.getcwd() + '/static/favicon.ico',
        #},
    }

    cherrypy.site = {'base_path': os.getcwd()}

    # Create an instance of MainApp and tell Cherrypy to send all requests under / to it. (ie all of them)
    cherrypy.tree.mount(server.MainApp(), "/", conf)
    cherrypy.tree.mount(server.ApiApp(), "/api/", conf)

    # Tell cherrypy where to listen, and to turn autoreload on
    cherrypy.config.update({
        'server.socket_host': LISTEN_IP,
        'server.socket_port': LISTEN_PORT,
        'engine.autoreload.on': True,
    })

    #cherrypy.tools.auth = cherrypy.Tool('before_handler', auth.check_auth, 99)

    print("========================================")
    print("             Emily Zou")
    print("         University of Auckland")
    print("   COMPSYS302 - Example client web app")
    print("========================================")

    # Start the web server
    cherrypy.engine.start()

    # And stop doing anything else. Let the web server take over.
    cherrypy.engine.block()
Example #2
0
def runMainApp():
    #set up the config
    conf = {
        '/': {
            'tools.staticdir.root': os.getcwd(),
            'tools.encode.on': True,
            'tools.encode.encoding': 'utf-8',
            'tools.sessions.on': True,
            'tools.sessions.timeout':
            60 * 1,  #timeout is in minutes, * 60 to get hours

            # The default session backend is in RAM. Other options are 'file',
        },

        #configuration for the static assets directory
        '/static': {
            'tools.staticdir.on': True,
            'tools.staticdir.dir': 'static',
        },

        #once a favicon is set up, the following code could be used to select it for cherrypy
        '/favicon.ico': {
            'tools.staticfile.on': True,
            'tools.staticfile.filename': os.getcwd() + '/static/favicon.ico',
        },
    }

    cherrypy.site = {'base_path': os.getcwd()}

    # Create an instance of MainApp and tell Cherrypy to send all requests under / to it. (ie all of them)
    cherrypy.tree.mount(server.MainApp(), "/", conf)
    #Mount API handler
    cherrypy.tree.mount(api.MainApp(), "/api/", conf)

    # Tell cherrypy where to listen, and to turn autoreload on
    cherrypy.config.update({
        'server.socket_host': LISTEN_IP,
        'server.socket_port': LISTEN_PORT,
        'engine.autoreload.on': True,
    })

    #cherrypy.tools.auth = cherrypy.Tool('before_handler', auth.check_auth, 99)

    print("crol453 Python Webserver")

    #Start the routine background tasks
    cherrypy.engine.reporter = cherrypy.process.plugins.BackgroundTask(
        120, reporter.main)
    cherrypy.engine.reporter.start()
    # Start the web server
    cherrypy.engine.start()

    # And stop doing anything else. Let the web server take over.
    cherrypy.engine.block()
Example #3
0
File: main.py Project: tgre605/A1
def run_main_app():
    conf = {
        '/': {
            'tools.staticdir.root': os.getcwd(),
            'tools.encode.on': True,
            'tools.encode.encoding': 'utf-8',
            'tools.sessions.on': True,
            'tools.sessions.timeout': 60 * 1, #timeout is in minutes, * 60 to get hours

            # The default session backend is in RAM. Other options are 'file',
        },

        '/static': {
            'tools.staticdir.on': True,
            'tools.staticdir.dir': 'static',
        },
    }

    cherrypy.site = {
        'base_path': os.getcwd()
    }
    database = DatabaseManager()
    database.init_db(DB_NAME)
    if CREATE_TEST_DATA:
        database.create_test_data()

    main_app = server.MainApp()
    main_app.api = api.base_api.BaseApi(database)
    cherrypy.tree.mount(main_app, "/", conf)

    cherrypy.config.update({'server.socket_host': LISTEN_IP,
                            'server.socket_port': LISTEN_PORT,
                            'engine.autoreload.on': True,
                           })

    print("========================================")
    print("           Softeng 701 Server")
    print("========================================")

    cherrypy.engine.start()

    cherrypy.engine.block()
Example #4
0
def runMainApp():
    # set up the config
    conf = {
        '/': {
            'tools.staticdir.root': os.getcwd(),
            'tools.encode.on': True,
            'tools.encode.encoding': 'utf-8',
            'tools.sessions.on': True,
            'tools.sessions.timeout': 60 * 1,
        },

        # configuration for the static assets directory
        '/static': {
            'tools.staticdir.on': True,
            'tools.staticdir.dir': 'static',
        },
    }

    cherrypy.site = {
        'base_path': os.getcwd()
    }

    # Create an instance of server Apps and tell CherryPy to send all requests to relevant endpoints
    cherrypy.tree.mount(server.MainApp(), "/", conf)
    cherrypy.tree.mount(server.ApiApp(), "/api/", conf)

    # Tell CherryPy where to listen, and to turn autoreload on
    cherrypy.config.update({
        'server.socket_host': LISTEN_IP,
        'server.socket_port': LISTEN_PORT,
        'engine.autoreload.on': True,
    })

    # Start the web server
    cherrypy.engine.start()

    # And stop doing anything else. Let the web server take over.
    cherrypy.engine.block()
Example #5
0
def run_main_app():
    conf = {
        '/': {
            'tools.staticdir.root': os.getcwd(),
            'tools.encode.on': True,
            'tools.encode.encoding': 'utf-8',
            'tools.sessions.on': True,
            'tools.sessions.timeout':
            60 * 1,  #timeout is in minutes, * 60 to get hours

            # The default session backend is in RAM. Other options are 'file',
        },
        '/static': {
            'tools.staticdir.on': True,
            'tools.staticdir.dir': 'static',
        },
    }

    cherrypy.site = {'base_path': os.getcwd()}

    cherrypy.tree.mount(server.ApiServer(), "/api/", conf)
    cherrypy.tree.mount(server.MainApp(), "/", conf)

    cherrypy.config.update({
        'server.socket_host': LISTEN_IP,
        'server.socket_port': LISTEN_PORT,
        'engine.autoreload.on': True,
    })

    print("========================================")
    print("           Softeng 701 Server")
    print("========================================")

    cherrypy.engine.start()

    cherrypy.engine.block()