A library for developing applications with a message-based protocol on top of TCP based on asyncio.
Project description
A library for developing applications with a message-based protocol on top of TCP based on asyncio.Opens the possibility of adding controllers that are responsible for specific commands, the ability to define and validate command arguments.
-
First, you need to create an object of the App class
import asyncio from main import App app = App() #Your code if __name__ == '__main__': asyncio.run(app.run())
-
Examples of some simple tasks that our framework uses.
import pydantic class Person(pydantic.BaseModel): name: str = pydantic.Field(..., min_length=2, max_length=250, description="The person's name must be at least 2 " "and at most 250 characters") age: int = pydantic.Field(..., ge=0, lt=200, description="The person's age must be greater or equal to zero " "and lesser than 250") funs: list[str] = pydantic.Field(default_factory=list, title="The activities person likes to do") salary: int = pydantic.Field(None, gt=0, description="The person's salary must be greater than zero") def __str__(self) -> str: return f'{self.name} is {self.age} years old with {self.salary}$ salary and favourite activities: {self.funs}' @app.command(name='sum') async def custom_sum(arg1: int, arg2: int) -> str: return str(arg1 + arg2) @app.command() async def add_person(person: Person): people.append(person) @app.command() async def get_person(name: str) -> str: return '\n'.join(str(person) for person in people if person.name == name)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Close
Hashes for asyncio_tcp_messages-0.0.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | e895bad822f809e5dfebc8dcb8b092996633813ed01defe80aceab5ac9aa82b7 |
|
MD5 | 2c710a9978dea868fd36f293ac959099 |
|
BLAKE2b-256 | 50480c0c40b0a9ff0ee4a35200bed46a7ca495b0c9115ee396bebfcb6149d761 |