πŸ“¦ encode / dashboard

An admin interface for ASGI Web frameworks.

β˜… 133 stars β‘‚ 7 forks πŸ‘ 133 watching βš–οΈ BSD 3-Clause "New" or "Revised" License
asgidashboarddatabaseorm
πŸ“₯ Clone https://github.com/encode/dashboard.git
HTTPS git clone https://github.com/encode/dashboard.git
SSH git clone git@github.com:encode/dashboard.git
CLI gh repo clone encode/dashboard
Tom Christie Tom Christie Update publish.yml (#21) 06a6fb1 5 years ago πŸ“ History
πŸ“‚ 06a6fb1054c233c578181f96e80030b17c230712 View all commits β†’
πŸ“ .github
πŸ“ dashboard
πŸ“ docs
πŸ“ scripts
πŸ“ tests
πŸ“„ .gitignore
πŸ“„ example.py
πŸ“„ LICENSE.md
πŸ“„ MANIFEST.in
πŸ“„ mkdocs.yml
πŸ“„ README.md
πŸ“„ requirements.txt
πŸ“„ setup.py
πŸ“„ README.md

An admin dashboard for use with ASGI web frameworks.

Work in progress.

example.py

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


database = databases.Database('sqlite:///test.db')
models = orm.ModelRegistry(database=database)
statics = StaticFiles(packages=['dashboard'])


class Notes(orm.Model):
    registry = models
    tablename = 'notes'
    fields = {
        'id': orm.Integer(title="ID", primary_key=True, read_only=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'),
    Mount("/statics", app=statics, name='static'),
    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.