Skip to main content

Pygeist server package

Project description

Pygeist

Pygeist is a Python module that abstracts the application layer protocol Zeitgeist implementation.

Tests License: MIT

Protocol

See here to look into the core implementation of the protocol.

.
├── core -> zeitgeist_core
├── adapters
├── pygeist
└── tests

Installation

This package is available for pip:

pip install pygeist

Quick endpoint example

Create

# example.py
from pygeist import ZeitgeistAPI, Request

app = ZeitgeistAPI()

async def main_handler(req: Request):
    return f'Hello! We got this: {req.body}'

app.get('/', main_handler, status_code=200)

Run

python3 -m pygeist example:app

Model support

This module utilizes Pydantic for both input and output handling of inputs:

# user.py
from pygeist import Router
from pydantic import BaseModel

class UserModel(BaseModel):
    name: str
    age: int

async def user_main():
    return {'name': 'test', 'age': 21}

async def is_adult(user: UserModel):
    return u.age >= 18

router = Router('/user')
router.get('/', user_main, status_code=200, response_model=UserModel)
router.get('/isadult', is_adult, status_code=200)

Testing

This module implements a TestClient allowing for a mock integration of a client interacting with the server. It is recommended to use the Pytest framework:

# tests.py
from pygeist import TestClient
from example import app
import pytest

@pytest.mark.asyncio
async def test_get():
    async with TestCient(app) as client:
        res = await client.get('/')
        assert res.status_code == 200

Contributing

Contributions, issues, and feature requests are welcome! Feel free to check the issues page or open a pull request.

To set up the project locally:

git clone https://github.com/mateogall0/pygeist
cd pygeist
xargs sudo apt-get -y install < packages.txt
make
pip install -r requirements-dev.txt
pytest

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pygeist-0.4.0.tar.gz (33.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pygeist-0.4.0-py3-none-any.whl (38.9 kB view details)

Uploaded Python 3

File details

Details for the file pygeist-0.4.0.tar.gz.

File metadata

  • Download URL: pygeist-0.4.0.tar.gz
  • Upload date:
  • Size: 33.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pygeist-0.4.0.tar.gz
Algorithm Hash digest
SHA256 bd324800b0fdd7bb7b5b8a27e08c849374ec819eaf9f22da8fc27fea724d9078
MD5 a204970359142be9cbfbc866abb2fb00
BLAKE2b-256 06a06a012de66fbc81be51987b372b8bb1459d453feccfa3424c46dabe270c61

See more details on using hashes here.

File details

Details for the file pygeist-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: pygeist-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 38.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pygeist-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e02cd928772ae1a35c62246e08c852bbb9e7c712666fb8d0429036e54eb7f2fb
MD5 e8d1f14220ca907dac39de0083b95576
BLAKE2b-256 8f341807e17843872367c6dcab529caec70029788acc083570a3d8325a17f917

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page