Releases: HapticX/happyx
Releases · HapticX/happyx
v2.9.2
v2.9.1
v2.6.1
Changelog
- Support multimethods for SSR/SSG (#117)
It available for Python also:
serve ....: [get, post] "/": ...
@app.route('/', ["get", "post"]) def handle(): pass
- Improved
.hpx
files (#118) - new statemenets:- if-elif-else
- while
- for
Full Changelog: v2.5.1...v2.6.1
v2.5.1
v2.5.0
Changelog
- Support
websockets
in Python bins (#115)@app.websocket('/ws') def handle_websocket_connection(ws: WebSocket): if ws.id() == 2: ws.send_text("failure") ws.close() print(ws.state()) print(ws.id()) if ws.state() == 'open': # connect/open/close/mismatch_protocol/handshake_error/error print(ws.receive_text()) ws.send_json({"hello": "world"})
What's Changed
- some minor design changes by @horanchikk in #114
New Contributors
- @horanchikk made their first contribution in #114
Full Changelog: v2.3.0...v2.5.0
v2.3.0
Changelog
- [
Python binds
] Compatibility with Jinja2 (#112)from happyx import new_server, setup_jinja2, TemplateResponse setup_jinja2('./my/dir/with/jinja2/templates') app = new_server() @app.get('/') def home(): return TemplateResponse('index.html')
- [
Python binds
] static files (#111)from happyx import new_server, static app = new_server() app.static('/static', directory='dir')
Python Bindings
Meet - Python Bindings! 👋
Since v2.2.4 you can use HappyX with Python 🐍
Install
pip install happyx
Usage
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
Full Changelog: v2.1.0...v2.2.4