Skip to main content

A Python Framework for writing Reactive web Front-Ends

Project description

Starfyre Logo

Discord

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 App

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>

🚀 Sample CLI usage

Usage: python -m starfyre [OPTIONS]

Options:
  --path TEXT      Path to the project
  --dev BOOLEAN    Start the compilation and generate the build package.
  --build BOOLEAN  Start the build package
  --help           Show this message and exit.

🗒️ How to contribute

🏁 Get started

Please read the code of conduct and go through CONTRIBUTING.md before contributing to Robyn. Feel free to open an issue for any clarifications or suggestions.

If you're feeling curious. You can take a look at a more detailed architecture here.

If you still need help to get started, feel free to reach out on our community discord.

⚙️ Developing Locally

  1. Install the dependencies poetry install
  2. Run the script ./build.sh. This command will run the build process in starfyre against the test application in test-application directory.
  • The build.sh file is a simple script that runs two commands sequentially.
    • python -m starfyre --dev=True --path="test-application/"
    • python -m starfyre --build=True --path="test-application/"
      • The path variable here is the path to our application.
      • The dev flag here is used to start the compilation and create the build directory.
      • The build directory is basically a python package that contains all the compiled files. We use the --build flag to run that package.
  1. You can find a small test application in the test-application directory.
  2. Navigate to test-application/dist and open index.html in your browser to see the output.

Running the sample app with Docker

Ideally, we should not be needing this. But if you are having trouble running the sample app locally, you can try this.

  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.2.tar.gz (11.7 kB view details)

Uploaded Source

Built Distribution

starfyre-0.6.2-py3-none-any.whl (12.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: starfyre-0.6.2.tar.gz
  • Upload date:
  • Size: 11.7 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.2.tar.gz
Algorithm Hash digest
SHA256 1d7c8f9d0f39576b121f2982ff6959aaaba87ce48d6aac08ef5a95f974d40e07
MD5 ecedc0f01435cd83b117f8c33ef62af2
BLAKE2b-256 93c3157f67d763ffe10202c0cb9fde14979f4704ad9983647f9404888ec9bb5b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: starfyre-0.6.2-py3-none-any.whl
  • Upload date:
  • Size: 12.2 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 53a0c9dcfcba6c309127e7d6466867dd98927482acf92c8f81b5378715b54f05
MD5 7d4ae3170f45fe081d8bae91719b1fae
BLAKE2b-256 bb56d24d6fe0ac287c90d3778c98f102a848c2c337745d75db169cd662c279d3

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