Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

Dashborg Python SDK

Dashborg is a SDK that plugs directly into any backend service or script. With a couple lines of code you can register any running function with the Dashborg service and then build secure, modern, interactive tools on top of those functions using a simple, JavaScript free, HTML template language.

Dashborg saves you time by handling all of the tedious details of frontend app creation and deployment (hosting, end-to-end security, authentication, transport, UI libraries, JavaScript frameworks, CSS frameworks, etc.).

Dashborg works great for debugging, introspecting the running state of servers, viewing/updating configuration values, bite-sized internal tools, status pages, and reports.

Dashborg is easy to get started with. You can have your first app deployed in 5-minutes (no account/registration required). Free tier covers most simple use cases.

Questions? Join the Dashborg Slack Channel

Dashborg Hello World

pip install dashborg-python-sdk
import dashborg
import asyncio

counter = 0

def test_fn():
    global counter
    counter += 1
    print(f"Calling TestFn counter={counter}")
    return {"message": "TestFn Output!", "counter": counter}

async def main():
    config = dashborg.Config(anon_acc=True, auto_keygen=True)
    client = await dashborg.connect_client(config)
    app = client.app_client().new_app("hello-world")
    app.set_html(file_name="hello-world.html", watch=True)
    app.runtime.handler("test-handler", test_fn, pure_handler=True)
    await client.app_client().write_app(app, connect=True)
    await client.wait_for_shutdown()

asyncio.run(main())

The HTML template to render your app (save as hello-world.html):

<app ui="dashborg">
  <h1>Hello World</h1>
  <div class="row xcenter">
    <d-button onclickhandler="$.output = /@app:test-handler">Run Test Handler</d-button>
    <d-stat label="Counter" bind="$.output.counter" defaultvalue="0"/>
  </div>
  <hr/>
  <d-dataview bind="$.output"/>
</app>

Run your program. A new public/private keypair will be created and used to secure your new Dashborg account. You'll also see a secure link to your new application. Click to view your application!

That's it. You've created and deployed, secure, interactive web-app that is directly calling code running on your local machine!

Adding BLOBs

Want to show an image, or add a CSV file your end users to download, here's how to do it:

    await client.global_fs_client().set_static_path("/image/myimage.jpg", file_name="./path-to-image.jpg", fileopts=dashborg.FileOpts(mimetype="image/jpeg"))
    await client.global_fs_client().set_static_path("/mydata.csv", file_name="./path-to-csv.csv", fileopts=dashborg.FileOpts(mimetype="text/csv"))

Show the image using a regular <img> tag in your HTML template. Using the path prefix "/@raw/" allows for raw http GET access to your uploaded content:

    <img src="/@raw/image/myimage.jpg" style="max-width: 500px;"/>

Download the CSV using a standard HTML download link:

    <a href="/@raw/mydata.csv" download>Download CSV</a>

Or use a Dashborg download control (defined in the standard Dashborg UI package) to make it look nice:

    <d-download path="/mydata.csv">Download CSV</d-download>

Adding Static Data

Dashborg uses JSON to transfer data between your app and the Dashborg service. You can send any static JSON-compatible data (bool, str, int, float, dict, list) to Dashborg using set_json_path(). Static data is available to apps even when there is no backend connected. For dynamic data, use a runtime handler. Here we'll set favorite color table to the path "/colors.json". We used the app_fs_client() instead of the global_fs_client(). That makes the data local to the app and is accessible at /@app/colors.json:

colors = []
colors.append({"name": "Mike", "color": "blue", "hex": "#007fff"})
colors.append({"name": "Chris", "color": "red", "hex": "#ee0000"})
colors.append({"name": "Jenny", "color": "purple", "hex": "#a020f0"})
await app.app_fs_client().set_json_path("/colors.json", colors)

Load the data into our datamodel using the <d-data> tag. Read from blob "colors", set it into the frontend data model at $.colors:

<d-data query="/@app/colors.json" output.bindpath="$.colors"/>

Show the first color name as text using <d-text>. Use the hex color to show a small color square using a background-color style (attributes and styles are dynamic when they starts with *):

<div>
    <d-text bind="$.colors[0].name"/>'s favorite color is <d-text bind="$.colors[0].color"/>:
    <div style="display: inline-block; vertical-align: bottom; width: 18px; height: 18px; background-color: *$.colors[0].hex"/>
</div>

You can loop using the built-in <d-foreach> tag (each element is bound to . inside the loop):

<ul class="ui bulleted list">
    <d-foreach bind="$.colors">
      <li class="item" style="height: 24px">
        <div class="row">
          <div><d-text bind=".name"/> - Favorite Color is <d-text bind=".color"/></div>
          <div style="width: 18px; height: 18px; background-color: * .hex"/>
        </div>
      </li>
    </d-foreach>
</ul>

Or use a Dashborg Table Control (@index is bound to the loop counter):

<d-table bind="$.colors">
   <d-col label="#" bind="@index+1"/>
   <d-col label="Name" bind=".name"/>
   <d-col label="Color" bind=".color"/>
   <d-col label="Swatch">
       <div style="width: 50px; height: 50px; background-color: * .hex"/>
   </d-col>
</d-table>

Security

All communication from your backend to the Dashborg service is done over HTTPS/gRPC. Your account is authenticated with a public/private keypair that can be auto-generated by the Dashborg SDK (AutoKeygen config setting).

The frontend is served over HTTPS, and each account is hosted on its own subdomain to prevent inter-account XSS attacks The Dashborg frontend offers pre-built authentication methods, with JWT tokens that are created from your private-key (the default for new anonymous accounts), simple passwords, or user logins.

Advanced Features

  • Write your own Dashborg components to reuse among your applications
  • Create staging/development zones to test your apps without affecting your production site
  • Assign roles to users (and passwords), set a list of allowed roles per app per zone
  • Navigate to the '/@fs' path on your Dashborg account to see all of your static data, applications, and handlers.

Metadata

Release files for dashborg-python-sdk 0.4.0.dev5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dashborg-python-sdk 0.4.0.dev5
File Size Uploaded
dashborg-python-sdk-0.4.0.dev5.tar.gz 30.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for dashborg-python-sdk 0.4.0.dev5
File Interpreter ABI Platform
dashborg_python_sdk-0.4.0.dev5-py3-none-any.whl Python 3 none any Details

Total release size: 58.2 kB

Release files / dashborg-python-sdk-0.4.0.dev5.tar.gz

Download URL dashborg-python-sdk-0.4.0.dev5.tar.gz
Size 30.0 kB
Tags Source
SHA-256 checksum
How to use checksums
34f650a46398c11761f609a045988b1755ae1a2598d271da2779f0c155c4a020
BLAKE2b-256 checksum
How to use checksums
6d41f6dd2f912561c34c5fdd6c20fab7363c4390c2705e7dcb91ec83dd0c63c4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.0

Release files / dashborg_python_sdk-0.4.0.dev5-py3-none-any.whl

Download URL dashborg_python_sdk-0.4.0.dev5-py3-none-any.whl
Size 28.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
61c745fc242591f7191441a8481b02b8cb5f63fd2572e440734073b39c535224
BLAKE2b-256 checksum
How to use checksums
0df0a66711a55ab3cb094c9ff791fe30f02865f3fbbd5953de18cbecdbae9c4c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.0
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page