| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
ObjectAPI provides a concise negative-boilerplate paradigm for creating full-stack web applications with Python. It is built on top of FastAPI, SQLModel, and pydantic.
pip install object-apifrom object_api.entity import Entity
from object_api.app import App
from object_api.model_variants import (
create_variant,
read_variant,
update_variant,
db_variant,
)
from object_api import router
from object_api.router import route, get, post, put, delete, patch, head, options
from object_api.servicemethod import servicemethodfrom object_api import (
App,
Entity,
create_variant,
read_variant,
update_variant,
db_variant,
router,
route,
get,
post,
put,
delete,
patch,
head,
options,
servicemethod
)
@create_variant()
@read_variant()
@update_variant()
@db_variant(include=["passwd_hash"])
class User(Entity):
name: str
passwd_hash: str = Field(exclude=True)
birthdate: datetime
@property
def age(self) -> timedelta:
return datetime.now() - self.birthdate
class User(Entity):
name: str
pass: str
age: int
@service.servicemethod
@classmethod
def remove_inactive(cls):
for user in User.get_all():
if user.age > 100:
user.delete()
@router.route()
def get_name(self):
return self.name
@router.post("/change_name")
def change_name(self, name: str):
self.name = name
self.save()
app = App()
app.run()https://github.com/ComputaCo/object-api
[] Make the Create/Read/UpdateModel's automatically convert foreign lists/dicts to just their ID's
| Back | FazBrowse Home | New Git URL |