UtilMeta 2.5.6

Creator: bradpython12

Last updated:

Add to Cart

Description:

UtilMeta 2.5.6

UtilMeta API Framework - Python

UtilMeta is a progressive meta-framework for backend applications, which efficiently builds declarative APIs based on the Python type annotation standard, and supports the integration of mainstream Python frameworks as runtime backend

Homepage: https://utilmeta.com/py
Documentation: https://docs.utilmeta.com/py/en/
Author: @voidZXL













Installation
pip install utilmeta

Core Features
Declarative Development
Using the declarative power from UtilMeta, you can easily write APIs with auto request validation, efficient ORM queries, and auto OpenAPI document generation

Progressive Meta Framework
UtilMeta developed a standard that support all major Python web framework like django, flask, fastapi (starlette), sanic, tornado as runtime backend, and support current projects using these frameworks to develop new API using UtilMeta progressively

Highly Flexible & Extensible
UtilMeta is highly flexible with a series of plugins including authentication (Session/JWT), CORS, rate limit, retry, and can be extended to support more features.
Full-lifecycle DevOps Solution
The UtilMeta Platform provided the full-lifecycle DevOps solution for this framework, the API Docs, Debug, Logs, Monitoring, Alerts, Analytics will all been taken care of in the platform

Hello World
Create a Python file named server.py and write the following code
from utilmeta import UtilMeta
from utilmeta.core import api
import django

class RootAPI(api.API):
@api.get
def hello(self):
return 'world'

service = UtilMeta(
__name__,
name='demo',
backend=django, # or flask / starlette / tornado / sanic
api=RootAPI,
route='/api'
)

app = service.application() # wsgi app

if __name__ == '__main__':
service.run()


You can use flask, starlette, sanic, tornado instead of django as runtime backend, just install them first and replace them in the demo code

Run
You can execute this file by python to run the server
python server.py

The following info Implies that the service has live
Running on http://127.0.0.1:8000
Press CTRL+C to quit

Then we can use our browser to open http://127.0.0.1:8000/api/hello to call this API directly, we will see
world

It means this API works
Examples
Declarative RESTful API
Declarative ORM in UtilMeta can handle relational queries concisely without N+1 problem, both sync and async queries are supported
from utilmeta.core import api, orm
from django.db import models

class User(models.Model):
username = models.CharField(max_length=20, unique=True)

class Article(models.Model):
author = models.ForeignKey(User, related_name="articles", on_delete=models.CASCADE)
content = models.TextField()

class UserSchema(orm.Schema[User]):
username: str
articles_num: int = models.Count('articles')

class ArticleSchema(orm.Schema[Article]):
id: int
author: UserSchema
content: str

class ArticleAPI(api.API):
async def get(self, id: int) -> ArticleSchema:
return await ArticleSchema.ainit(id)

if you request the ArticleAPI like GET /article?id=1, you will get the result like
{
"id": 1,
"author": {
"username": "alice",
"articles_num": 3
},
"content": "hello world"
}

This conforms to what you declared, and the OpenAPI docs will be generated automatically
Migrate
Integrate current django/flask/fastapi/... project with UtilMeta API is as easy as follows
import django
from django.urls import re_path
from django.http.response import HttpResponse
from utilmeta.core import api, response

class CalcAPI(api.API):
@api.get
def add(self, a: int, b: int) -> int:
return a + b

def django_test(request, route: str):
return HttpResponse(route)

urlpatterns = [
re_path('test/(.*)', django_test),
CalcAPI.__as__(django, route='/calc'),
]

Integrate with Flask example
from flask import Flask
from utilmeta.core import api, response

app = Flask(__name__)

@app.route("/")
def hello_world():
return "<p>Hello, World!</p>"

class CalcAPI(api.API):
@api.get
def add(self, a: int, b: int) -> int:
return a + b

CalcAPI.__as__(app, route='/calc')

Quick Guide
We have several introductory case tutorials from easy to complex, covering most usage of the framework. You can read and learn in the following order.

BMI Calculation API
User Login & RESTful API
Realworld Blog Project
Websocket Chatroom (coming soon)

If you prefer to learn from a specific feature, you can refer to

Handle Request: How to handle path, query parameters, request body, file upload, request headers and cookies.
API Class and Routing How to use API class mounts to define tree-like API routing, and use hooks to easily reuse code between APIs, handle errors, and template responses.
Schema query and ORM How to use Schema to declaratively write the CRUD query, and ORM operations required by a RESTful interface.
API Authentication: How to use Session, JWT, OAuth and other methods to authenticate the request of the interface, get the current request's user and simplify the login operation
Config, Run & Deploy: How to configure the run settings, startup, and deployment of a service using features such as declarative environment variables
Migrate from current project How to progressively integrate UtilMeta API to an existing backend project or migrate to UtilMeta

Community
Join our community to build great things together

Discord
X(Twitter)
Reddit
中文讨论区

Enterprise Solutions & Support
The UtilMeta team is providing custom solutions and enterprise-level support at

https://utilmeta.com/solutions

You can also contact us in this page
Wechat
Contact the creator's wechat for support or join the developers wechat group

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Customer Reviews

There are no reviews.