Coder Social home page Coder Social logo

livioribeiro / selva Goto Github PK

View Code? Open in Web Editor NEW
6.0 4.0 0.0 970 KB

Python ASGI web framework

Home Page: https://livioribeiro.github.io/selva/

License: MIT License

Python 99.99% HTML 0.01%
python asyncio web framework websocket selva api json pydantic python-types

selva's Introduction

Project Selva

Documentation: https://livioribeiro.github.io/selva/

Selva is a Python ASGI web framework built on top of asgikit and inspired by Spring Boot, AspNet, FastAPI and Go's net/http.

It features a Dependency Injection system to help build robust and reliable applications.

Quick start

Install selva and uvicorn to run application:

pip install selva uvicorn[standard]

Create a module called application.py:

touch application.py

Create a controller:

from asgikit.requests import Request
from asgikit.responses import respond_text
from selva.web import controller, get


@controller
class Controller:
    @get
    async def hello(self, request: Request):
        await respond_text(request.response, "Hello, World!")

Run application with uvicorn (Selva will automatically load application.py):

uvicorn selva.run:app --reload

selva's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

selva's Issues

Add di interceptor registration

DI Interceptors can intercept the creation of services. This can be used, for example, to add a caching behavior to some functions in a service that meet a specific predicate

Add background services

Add support for creating services that are instantiated on application startup and run until application is shutdown.

These services may loop waiting for events, for example, listening for rabbitmq events, and should handle StopIteration or InterruptedError

Configure individual parts of the logging dict configuration

Users should be able to configure parts of the logging configuration without overriding the whole configuration dict, unless it is explicitly overriden, like the following:

LOGGING_FORMATTERS = {
    "default": {
        "format": "{asctime} | {levelname:<8} | {name} - {message}",
        "style": "{",
        "datefmt": "%Y-%m-%d %H:%M:%S",
    },
}

LOGGING_HANDLERS = {
    "console": {
        "class": "logging.StreamHandler",
        "formatter": "default",
    },
}

LOGGING_LOGGERS = {
    "selva": {
        "handlers": ["console"],
        "level": "WARNING",
    },
    "application": {
        "handlers": ["console"],
        "level": "INFO",
    },
}

Parametrize FromRequest converters

For example:

from selva.seb impor controller, get
from selva.web.converters import Json

@controller
class Controller:
    @get
    def handler(self, model: Model = Json()):
        ...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.