Skip to main content

Building web apps without manually creating widgets

Project description

Funix.IO
⭐️ The laziest way to build AI/data apps in Python. ⭐️

Features

Funix is designed for an algorithm/ML engineer to build apps without writing code related to the UI, not even selecting a widget and passing it to or calling it in a Python function.

  • Minimalist: Automatic UI generation. No manual widget selection.
  • Centralized styling: Type-to-widget mapping stored in themes for cross-app UI consistency.
  • Declarative: All non-default controls, including UI customization, via Python dictionaries.
  • Non-intrusive: You can still run or debug your Python code locally as usual.

WIP: Funix is still under development. If you have any questions, please feel free to open an issue.

Hello, world in Funix

Building a web app in Funix is super easy. Just have a type-hinted Python function:

def hello(your_name: str) -> str:
    return f"Hello, {your_name}."

Save in a file (say hello.py) and pass to Funix:

funix -l hello.py

A web app will be launched at http://localhost:3000 and automatically opened in a browser window.

screenshots/hello.png

Note: The -l flag stands for "lazy" meaning that only default settings are used. It cannot be used when your function is decorated by the funix decorator @funix() which allows you to customize your app. See example usages below of the decorator.

Love Funix? Give us a star

Borrowed from AppFlowy

Installation

  • From PyPI (stable)

    pip install funix
    
  • From GitHub (latest)

    pip install "git+https://github.com/TexteaInc/funix.git"
    
  • Local development

    git clone https://github.com/TexteaInc/funix
    cd funix
    pip install -e . 
    

    Add --prefix=~/.local if pip insists to install to system paths. See #24 and #23

Gallery

More examples in QuickStart Guide or the examples folder.

ChatGPT, multi-turn

Code here. Just 77 lines including the HTML layout code and tip messages.

Multiturn chat

Shortest Dall-E web app in Python

from funix import funix                      # add line one
from funix.hint import Images                # add line two
import openai  # pip install openai

openai.api_key = os.environ.get("OPENAI_KEY")

@funix()                                     # add line three
def dalle(prompt: str = "a cat") -> Image:
    response = openai.Image.create(prompt=prompt, n=1, size="1024x1024")
    return response["data"][0]["url"]

Dalle demo

Compound UIs

from typing import List
import matplotlib.pyplot as plt
from matplotlib.figure import Figure

@funix(
        widgets={
           "a": "sheet",
           "b": ["sheet", "slider[0,1,0.01]"]
        }
)

# below is a simple matplotlib function
def table_plot(a: List[int], b: List[float]) -> Figure:
    fig = plt.figure()
    plt.plot(a, b)
    return fig

table plot demo static

Layout

Code here

shipping example

Usage

Command line

funix [-h] [-H 127.0.0.1] [-p 3000] [-F] [-B] 

Funix: Building web apps without manually creating widgets

positional arguments:
  main_class            The Python module containing functions 
                        to be turned into web apps by Funix 

options:
  -h, --help            show this help message and exit
  -H 127.0.0.1, --host 127.0.0.1
                        Host of frontend and backend
  -p 3000, --port 3000  Port of frontend and backend
  -F, --no-frontend     Disable frontend server
  -B, --no-browser      Disable auto open browser

The command funix above is equivalent to python -m funix if you have installed Funix.

For example, to launch examples in the examples folder, run the following command:

cd examples
funix examples # same as `python -m funix examples`
funix examples_better # same as `python -m funix examples_better`

Call funix in Python

Besides starting Funix servers from the command line, you can also start Funix from Python:

import funix 
funix.run("localhost", 4010, "examples")

How to contribute

Funix is open-sourced under the MIT License. Community contribution is not only welcomed but desired. Feel free to fork and make a pull request when you are ready. You can also report bugs, suggest new features, etc. via the issue tracker.

Acknowledgement

Funix draws inspiration from FastAPI and Plac: building software interfaces by inferring from function signartures containing type hints. We port this idea from the backend (FastAPI) or the terminal (Python-Fire) to the frontend. We also wanna thank Streamlit, Gradio, PyWebIO, and Pynecone. They inspired us. We are just too lazy to manually define widgets imperatively. Funix’s backend is implemented in Flask and the frontend in Material UI. Lastly, Funix was made possible with the generous investment from Miracle Plus (formerly Y Combinator China) to Textea Inc.

Team

The Funix team at Textea consists of:

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

funix-0.4.5.tar.gz (2.4 MB view hashes)

Uploaded Source

Built Distribution

funix-0.4.5-py3-none-any.whl (2.4 MB view hashes)

Uploaded Python 3

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