예제 #1
0
)
import targ
import uvicorn

APP = create_admin([Director, Movie],
                   auth_table=User,
                   session_table=Sessions,
                   read_only=True)


def sandbox(host: str = "localhost", port: int = 8080):
    """
    Run the Piccolo Admin in read only mode with a SQLite database.

    :param host:
        Which host to serve the app on.
    :param host:
        Which port to serve the app on.

    """
    set_engine()
    create_schema(persist=False)
    populate_data()
    uvicorn.run(APP, host=host, port=port)


if __name__ == "__main__":
    cli = targ.CLI()
    cli.register(sandbox)
    cli.run(solo=True)
예제 #2
0
    Start the Piccolo admin.

    :param persist:
        If True, we don't rebuild all of the data each time.
    :param engine:
        Options are sqlite and postgres. By default sqlite is used.
    :param inflate:
        If set, this number of extra rows are inserted containing dummy data.
        This is useful when you need to test with lots of data. Example
        `--inflate=10000`.

    """
    set_engine(engine)
    create_schema(persist=persist)

    if not persist:
        populate_data(inflate=inflate, engine=engine)

    # Server
    class CustomConfig(Config):
        use_reloader = True
        accesslog = "-"

    asyncio.run(serve(APP, CustomConfig()))


if __name__ == "__main__":
    cli = targ.CLI(description="Piccolo Admin")
    cli.register(run)
    cli.run(solo=True)
예제 #3
0
def main():
    cli = targ.CLI(description="Piccolo Admin")
    cli.register(run)
    cli.run(solo=True)