def make_app():
    data_app = sticky_make_app()
    site_dir = os.path.join(os.path.dirname(here), "site")
    static_app = StaticURLParser(site_dir, cache_max_age=0)
    if not os.path.exists(site_dir):
        print "Error: %s doesn't exists" % site_dir
        sys.exit(1)
    app = Cascade([static_app, data_app])
    return app
def serve_app(port, database, config, setup):
    os.environ["CONFIG_MYSQL_SQLALCHEMY"] = database
    os.environ["DEBUG_STICKYREPO"] = "1"
    os.environ["SILVER_APP_CONFIG"] = config
    os.environ["TEMP"] = "/tmp"
    if setup:
        data_app = sticky_make_app()
        data_app.create_database(None)
        print "Database created"
    else:
        app = make_app()
        serve(app, port=port)