示例#1
0
def make_wsgi_app(redisserver, blob_folder='', url="/"):
    """Create a wsgi application which can be served by a WSGI compatable web server.
    Reads and writes to redis stores created by indi-mr

    :param redisserver: Named Tuple providing the redis server parameters
    :type redisserver: namedtuple
    :param blob_folder: Folder where Blobs will be stored
    :type blob_folder: String
    :param url: URL at which the web service is served
    :type url: String
    :return: A WSGI callable application
    :rtype: skipole.WSGIApplication
    """
    if not SKIPOLE_AVAILABLE:
        return

    if blob_folder:
        blob_folder = pathlib.Path(blob_folder).expanduser().resolve()

    # The web service needs a redis connection, available in tools
    rconn = tools.open_redis(redisserver)
    proj_data = {
        "rconn": rconn,
        "redisserver": redisserver,
        "blob_folder": blob_folder
    }
    application = WSGIApplication(project=PROJECT,
                                  projectfiles=PROJECTFILES,
                                  proj_data=proj_data,
                                  start_call=_start_call,
                                  submit_data=_submit_data,
                                  end_call=_end_call,
                                  url=url)

    if url.endswith("/"):
        skisurl = url + "lib"
    else:
        skisurl = url + "/lib"

    skis_application = skis.makeapp()
    application.add_project(skis_application, url=skisurl)

    return application
if __name__ == "__main__":

    import os

    PROJECTFILES = os.path.dirname(
        os.path.dirname(
            os.path.dirname(os.path.dirname(os.path.realpath(__file__)))))
    PROJECT = 'headersDropDownButton1'

    application = makeapp(PROJECTFILES)

    from skipole import skiadmin, skis, skilift, set_debug

    set_debug(True)

    skis_application = skis.makeapp()
    application.add_project(skis_application, url='/lib')

    skiadmin_application = skiadmin.makeapp(editedprojname=PROJECT)
    application.add_project(skiadmin_application, url='/skiadmin')

    from skipole import skilift

    # serve the application

    host = "127.0.0.1"
    port = 8000
    print("Serving %s on port %s" % (PROJECT, port))

    skilift.development_server(host, port, application)