Skip to main content

A Python Framework for writing Reactive web Front-Ends

Project description

Starfyre Logo

Starfyre ⭐🔥

Introduction:

Starfyre is a library that allows you to build reactive frontends using only Python. It is built using pyodide and wasm, which enables it to run natively in the browser. With Starfyre, you can create interactive, real-time applications with minimal effort. Simply define your frontend as a collection of observables and reactive functions, and let Starfyre handle the rest.

Please note that Starfyre is still very naive and may be buggy, as it was developed in just five days. However, it is under active development and we welcome contributions to improve it. Whether you are a seasoned web developer or new to frontend development, we hope that you will find Starfyre to be a useful tool. Its intuitive API and simple, declarative style make it easy to get started, and its powerful features allow you to build sophisticated applications.

Installation:

pip install starfyre

A sample project is hosted on GitHub.

Sample Usage

src/init.fyre

from .parent import parent
from .store import store

def mocked_request():
  return "fetched on the server"


async def handle_on_click(e):
  alert("click rendered on client")
  if 1==1:
    print("Hello world")

  current_value = get_parent_signal()
  set_parent_signal(current_value + 1)
  a = await fetch('https://jsonplaceholder.typicode.com/todos/1')
  print(await a.text())
  print("handles on click")
  

<style>
  body {
    background-color: red;
  }
</style>

<pyml>
  <store>
    <parent hello='world'>
        <span onclick={handle_on_click}>
          {[ mocked_request() for i in range(4)]}
        </span>
    </parent>
  </store>
</pyml>


<script>
// this is the optional section 
// for third party scripts and custom js
</script>

src/parent.fyre

import requests

def ssr_request():
  text = "Hello"
  if text != "":
    return text + " from Server Side"
  else:
    return "No response"

<pyml>
    <span>
      <div>
        {ssr_request()}
      </div>
      <b>
        {use_parent_signal()}
      </b>
      <b>
        {get_parent_signal()}
      </b>
      <div> 
        This won't be re-rendered
      </div>
    </span>
</pyml>

src/store.fyre

--client 
use_parent_signal, set_parent_signal, get_parent_signal = create_signal(2)

use_clock_signal, set_clock_signal, _ = create_signal(0)
---

Developing Locally

  1. Run the script ./build.sh
  2. You can find a small test application in the test-application directory.

Running the sample app with Docker

  1. Build the image docker build --tag starfyre .
  2. Run the container docker run -v ./test-application:/app/test-application/ starfyre
  3. Check the test-application directory for build and dist directories that contain the outputs
  4. If you would like to develop interactively inside the container, run docker run -it -v ./test-application:/app/test-application/ starfyre bash

Feedback

Feel free to open an issue and let me know what you think of it.

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

starfyre-0.6.1.tar.gz (10.8 kB view details)

Uploaded Source

Built Distribution

starfyre-0.6.1-py3-none-any.whl (11.8 kB view details)

Uploaded Python 3

File details

Details for the file starfyre-0.6.1.tar.gz.

File metadata

  • Download URL: starfyre-0.6.1.tar.gz
  • Upload date:
  • Size: 10.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.17

File hashes

Hashes for starfyre-0.6.1.tar.gz
Algorithm Hash digest
SHA256 75a6db4691cf94d80c9dbbef7ab8ed72205070666a3ee6179836d9ff1fec0dfd
MD5 063cda9fb48a76cadb27c6cf27632a8b
BLAKE2b-256 28c3c25cf1056eb6df85f4dcbbe5cbfda5d99d7d0e87583aca09932be0f55c4e

See more details on using hashes here.

File details

Details for the file starfyre-0.6.1-py3-none-any.whl.

File metadata

  • Download URL: starfyre-0.6.1-py3-none-any.whl
  • Upload date:
  • Size: 11.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.17

File hashes

Hashes for starfyre-0.6.1-py3-none-any.whl
Algorithm Hash digest
SHA256 91f078596f5e015e5969d59563cca719be443475134164789a6277185af0a910
MD5 28a8135fc192afe541e62e9e3863b194
BLAKE2b-256 1100df610318b59ae10d3c4a9fe33a191976ea35f25cab6af9839e9c55334093

See more details on using hashes here.

Supported by

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