Molten: A modern Python (3.6+) web framework

Release v0.5.2. (Installation, Changelog, Discuss, Source Code)

molten is a minimal, extensible, fast and productive framework for
building HTTP APIs with Python.
Here’s a quick taste:
from molten import App, Route

def hello(name: str, age: int) -> str:
return f”Hi {name}! I hear you’re {age} years old.”

app = App(routes=[Route(“/hello/{name}/{age}”, hello)])

For more, take a look at the examples folder in the GitHub repo.

Features
Here’s a selection of molten’s features that we’re most proud of.

Request Validation
molten can automatically validate requests according to predefined
schemas, ensuring that your handlers only ever run if given valid
input:
from molten import App, Route, field, schema
from typing import Optional

@schema
class Todo:
id: Optional[int] = field(response_only=True)
description: str
status: str = field(choices=[“todo”, “done”], default=”todo”)

def create_todo(todo: Todo) -> Todo:
# Do something to store the todo here…
return todo

app = App(routes=[Route(“/todos”, create_todo, method=”POST”)])

Schemas are PEP484-compatible, which means mypy and molten go
hand-in-hand, making your code more easy to maintain. Schema
instances are automatically serializable and you can pick and
choose which


Original URL: http://feedproxy.google.com/~r/feedsapi/BwPx/~3/4x2_p3Qqayk/index.html

Original article

Comments are closed.

Proudly powered by WordPress | Theme: Baskerville 2 by Anders Noren.

Up ↑

%d bloggers like this: