Skip to main content

An admin dashboard.

Project description

An admin dashboard for use with ASGI web frameworks.

Work in progress.

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",, 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.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for dashboard, version 0.0.6
Filename, size File type Python version Upload date Hashes
Filename, size dashboard-0.0.6-py3-none-any.whl (201.1 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size dashboard-0.0.6.tar.gz (195.9 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page