Download Latest Version v4.5.2 source code.tar.gz (2.7 MB)
Email in envelope

Get an email when there's a new version of happyx

Home / v2.2.4
Name Modified Size InfoDownloads / Week
Parent folder
Python Bindings source code.tar.gz 2023-08-16 768.4 kB
Python Bindings source code.zip 2023-08-16 822.3 kB
Python Bindings.tar.gz 2023-08-16 768.4 kB
Python Bindings.zip 2023-08-16 822.3 kB
README.md 2023-08-16 1.2 kB
Totals: 5 Items   3.2 MB 0

Meet - Python Bindings! šŸ‘‹

Since v2.2.4 you can use HappyX with Python šŸ

Install

:::bash
pip install happyx

Usage

:::py
from happyx import new_server, HttpRequest, RequestModelBase, JsonResponse


class User(RequestModelBase):
    name: str
    age: int


app = new_server("127.0.0.1", 5000)
user = new_server()

app.mount("/user", user)

@app.get('/')
def home(request: HttpRequest):
    print(request)
    return "Hello, world!"

@user.get('/')
def user_home(a: int, b: float, c: bool = true):
    """
    Try to send GET request to localhost:5000/user/
    And try to send queries:
    ?a=5&b=10.4&c=off
    """
    return f"Hello, world! a={a}, b={b}, c={c}"

@user.post('/[u]')
def create_user(u: User):
    print(u)
    print(u.name)
    print(u.age)
    return u.to_dict()

app.start()

Changelog

  • Python Bindings šŸ (#91)
  • Python in HappyX CLI (#105)

Full Changelog: https://github.com/HapticX/happyx/compare/v2.1.0...v2.2.4

Source: README.md, updated 2023-08-16