Skip to main content

An admin dashboard.

Project description

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])

Project details


Download files

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

Source Distribution

dashboard-0.0.2.tar.gz (195.5 kB view details)

Uploaded Source

File details

Details for the file dashboard-0.0.2.tar.gz.

File metadata

  • Download URL: dashboard-0.0.2.tar.gz
  • Upload date:
  • Size: 195.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.6

File hashes

Hashes for dashboard-0.0.2.tar.gz
Algorithm Hash digest
SHA256 864914b0987143f8d241d8b7e972b2bf8448a8cdd06f7bd47a5897a34faf1278
MD5 f72b19dae7c6cae047748418f47ae688
BLAKE2b-256 370a574e1f20fdfc9e3e3332699343c6a2177da524183dc17c0013144e71256f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page