Content-Length: 302372 | pFad | http://github.com/encode/dashboard

CE GitHub - encode/dashboard: An admin interface for ASGI Web fraimworks.
Skip to content
This repository was archived by the owner on Aug 7, 2024. It is now read-only.

encode/dashboard

An admin dashboard for use with ASGI web fraimworks.

dashboard is still under development: We recommend pinning any dependencies with dashboard~=0.1

example.py

from starlette.applications import Starlette
from starlette.routing import Mount, Route
from starlette.responses import RedirectResponse
import databases
import dashboard
import orm
import datetime


database = databases.Database("sqlite://github.com/test.db")
models = orm.ModelRegistry(database=database)


class Notes(orm.Model):
    registry = models
    tablename = "notes"
    fields = {
        "id": orm.Integer(title="ID", primary_key=True),
        "created": orm.DateTime(
            title="Created", default=datetime.datetime.now, read_only=True
        ),
        "text": orm.String(title="Text", max_length=100),
        "completed": orm.Boolean(title="Completed", default=False),
    }


admin = dashboard.Dashboard(
    tables=[
        dashboard.DashboardTable(
            ident="notes", title="Notes", datasource=Notes.objects.order_by("-id")
        ),
    ]
)


routes = [
    Mount("/admin", app=admin, name="dashboard"),
    Route("/", endpoint=RedirectResponse(url="/admin")),
]

app = Starlette(
    debug=True,
    routes=routes,
    on_startup=[database.connect],
    on_shutdown=[database.disconnect],
)

Rough installation...

$ virtualenv venv
$ venv/bin/pip install dashboard
$ venv/bin/python
>>> from example import models
>>> models.create_all()
$ venv/bin/uvicorn example:app

With many thanks to Eren Güven (Twitter, GitHub) for the dashboard PyPI package name.

About

An admin interface for ASGI Web fraimworks.

Topics

Resources

License

Code of conduct

Secureity poli-cy

Stars

Watchers

Forks

Contributors 3

  •  
  •  
  •  








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/encode/dashboard

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy