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. Advanced examples below use decorators. For more details of the decorator values, please refer to the reference manual.

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")

Front-end

Normally, Funix will start the front-end by itself. If you need to develop or debug the front-end (hopefully without scaring you) please go through the following steps:

  1. If you haven't finished git clone, clone the repo first.
  2. cd funix/frontend
  3. yarn install
  4. yarn start

Now, local Funix is athttp://localhost:3000/You can just use yarn funix:start command to open the front-end bound to port 8080 (the back-end service)

Exposing a Funix-converted app to the public

python3 -m funix [module] --host [your_server_ip]

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.8.tar.gz (2.4 MB view details)

Uploaded Source

Built Distribution

funix-0.4.8-py3-none-any.whl (2.4 MB view details)

Uploaded Python 3

File details

Details for the file funix-0.4.8.tar.gz.

File metadata

  • Download URL: funix-0.4.8.tar.gz
  • Upload date:
  • Size: 2.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for funix-0.4.8.tar.gz
Algorithm Hash digest
SHA256 06e53096fcf47e09f49e5f19ba8c89054c78731bf8c1efccef0c490def063006
MD5 178e95b8eb05a943d70e7a09a8c1b53f
BLAKE2b-256 9968d3475d7f1665e9fb2816989af74862fed161bcd16963e215622b44a045d1

See more details on using hashes here.

File details

Details for the file funix-0.4.8-py3-none-any.whl.

File metadata

  • Download URL: funix-0.4.8-py3-none-any.whl
  • Upload date:
  • Size: 2.4 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for funix-0.4.8-py3-none-any.whl
Algorithm Hash digest
SHA256 5a5b469ce525c97c6921c984e27b1f6a1a640053bfe29736e8bcc03337146809
MD5 63e9ddc5821bd67abbf69bf5258cc991
BLAKE2b-256 ac00e9a26e3156a9ef8fd2a005e76a5e31e81466e60fe518d37ff211d5ff3aaa

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