Skip to main content

Dars is a Python UI framework for building modern, interactive web apps with only Python code. Write your interface in Python, export it to static HTML/CSS/JS, and deploy anywhere.

Project description

Dars Framework

Dars is a Python UI framework for building modern, interactive web apps with Python code. Write your interface in Python, export it to static HTML/CSS/JS, and deploy anywhere.

pip install dars-framework

Some Javascript or frontend stack required.

Try dars without installing nothing just visit the Dars Playground

How It Works

  • Build your UI using Python classes and components (like Text, Button, Container, Page, etc).
  • Preview instantly with hot-reload using app.rTimeCompile().
  • Export your app to static web files with a single CLI command.
  • Use multipage, layouts, scripts, and more—see docs for advanced features.
  • For mor information visit the Documentation

Quick Example: Your First App

Note: this is an single page example but you can build multipage apps with Page component see the Components Documentation to know more.

from dars import App, Container, Text, Button, InlineScript

app = App()

# Crear aplicación con sintaxis nueva (v1.0.3)
container = Container(
    Text(
        "Hola Dars",
        style={'font-size': '32px', 'color': '#333'}
    ),
    Button(
        "Hacer clic",
        style={'background-color': '#007bff', 'color': 'white'}
    ),
    style={
        'display': 'flex',
        'flex-direction': 'column',
        'align-items': 'center',
        'padding': '40px'
    }
)

# Script para interactividad
script = InlineScript("""
document.addEventListener('DOMContentLoaded', function() {
    const boton = document.querySelector('button');
    boton.addEventListener('click', function() {
        alert('Hola desde Dars.');
    });
});
""")

# Ensamblar aplicación
app.set_root(container)
app.add_script(script)

if __name__ == "__main__":
    app.rTimeCompile()  # Live preview at http://localhost:8000

CLI Usage

Command What it does
dars export my_app.py --format html Export app to HTML/CSS/JS in ./my_app_web
dars preview ./my_app_web Preview exported app locally
dars init my_project Create a new Dars project
dars info my_app.py Show info about your app
dars formats List supported export formats
dars --help Show help and all CLI options

More

Local Execution and Live Preview

To test your app locally before exporting, use the hot-reload preview from any Python file that defines your app:

if __name__ == "__main__":
    app.rTimeCompile()

Then run your file directly:

python my_app.py

This will start a local server at http://localhost:8000 so you can view your app in the browser—no manual export needed. You can change the port with:

python my_app.py --port 8088

You can also use the CLI preview command on an exported app:

dars preview ./my_exported_app

This will start a local server at http://localhost:8000 to view your exported app in the browser.

Project details


Release history Release notifications | RSS feed

This version

1.1.2

Download files

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

Source Distribution

dars_framework-1.1.2.tar.gz (150.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dars_framework-1.1.2-py3-none-any.whl (177.4 kB view details)

Uploaded Python 3

File details

Details for the file dars_framework-1.1.2.tar.gz.

File metadata

  • Download URL: dars_framework-1.1.2.tar.gz
  • Upload date:
  • Size: 150.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.9

File hashes

Hashes for dars_framework-1.1.2.tar.gz
Algorithm Hash digest
SHA256 65fdf5a83e1e933014d599e4b6896dd57573f7e1f785c18b957f311cd0e44fda
MD5 71b02d1088bed78a6f3704973f8346d9
BLAKE2b-256 dc2fb77946d9ea419b9baefe179e91172479acb53bc13aaccec41fe68cda4d6d

See more details on using hashes here.

File details

Details for the file dars_framework-1.1.2-py3-none-any.whl.

File metadata

  • Download URL: dars_framework-1.1.2-py3-none-any.whl
  • Upload date:
  • Size: 177.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.9

File hashes

Hashes for dars_framework-1.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 834e4ea12733e6e1bb631f0098ea9d3c81ff4b9e705068c923f7bfed0a12a1e3
MD5 9a9cf43297b407c6212b13401327b546
BLAKE2b-256 4d0fb804e4bc0d29c5ff8afdbcb3f0057355b7c04702fa47b162ca8b3871450e

See more details on using hashes here.

Supported by

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