Skip to main content

A light-weight wsgi web framework

Project description

Build Status Build Status Coverage Status PyPI - License Python Versions Open Source Love Documentation Status

Eynnyd web framework logo

Eynnyd Web Framework

Eynnyd (pronounced [Ey-nahyd]) is an acronym for Everything You Need, Nothing You Don't. It is a light-weight WSGI compliant python 3 web framework. Eynnyd was designed with the primary goal to not impose bad engineering decisions on it's users. It is also designed to not overstep or assume the wants of it's user.

Simplicity and Freedom is the Design

This is the framework for you if the following sound good:

  • You are permitted but not coerced into following REST.
  • A request handler takes a request and returns a response.
  • A request interceptor takes a request and returns a request.
  • A response interceptor takes a request and a response and returns a response.
  • You can have any number of request interceptors, request handlers, or response interceptors.
  • You can name your handler methods anything you want.
  • You can limit the scope (paths it applies to) of any interceptor.
  • We do not provide extraneous dependencies or opinions (like database connection libraries or templating engines)
  • There is no Eynnyd way to do things.
  • There is nothing clever or magic. (like global singletons or special decorators)
  • You can see your entire routing layout, succinctly, in your main.

If this at all sounds good we recommend you keep reading and see what else Eynnyd can provide for you.

Documents

Read the documents at eynnyd.readthedocs.io

How to install it

Eynnyd is published to pypi and can be installed using:

pip install eynnyd

How to use it

Eynnyd does not come with a built in WSGI HTTP server. We recommend gunicorn for running your application.

A simple hello world example looks like:

# hello_world_app.py
from eynnyd import RoutesBuilder
from eynnyd import EynnydWebappBuilder
from eynnyd import ResponseBuilder
from http import HTTPStatus

def hello_world(request):
    return ResponseBuilder()\
        .set_status(HTTPStatus.OK)\
        .set_utf8_body("Hello World")\
        .build()


def build_application():
    routes = \
        RoutesBuilder()\
            .add_handler("GET", "/hello", hello_world)\
            .build()

    return EynnydWebappBuilder()\
            .set_routes(routes)\
            .build()

application = build_application()

Using gunicorn this can now be run gunicorn hello_world_app.

An example with interceptors

# hello_world_app.py
import logging

from eynnyd import RoutesBuilder
from eynnyd import EynnydWebappBuilder
from eynnyd import ResponseBuilder
from http import HTTPStatus

LOG = logging.getLogger("hello_world_app")

def hello_world(request):
    return ResponseBuilder()\
        .set_status(HTTPStatus.OK)\
        .set_utf8_body("Hello World")\
        .build()

def log_request(request):
    LOG.info("Got Request: {r}".format(r=request))
    return request

def log_response(request, response):
    LOG.info("Built Response: {s} for Request: {r}".format(s=response, r=request))
    return response

def build_application():
    routes = \
        RoutesBuilder()\
            .add_request_interceptor("/hello", log_request)\
            .add_handler("GET", "/hello", hello_world)\
            .add_response_interceptor("/hello", log_response)\
            .build()

    return EynnydWebappBuilder()\
            .set_routes(routes)\
            .build()

application = build_application()

For Developers / Contributors

Installing requirements

run:

pip install -r test_requirements.txt

Running the tests

After installing the requirements run:

python -m unittest discover tests

Checking coverage

After installing the requirements run:

coverage run --source eynnyd/ -m unittest discover tests/
coverage report

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

eynnyd-0.4.1.tar.gz (38.8 kB view details)

Uploaded Source

Built Distribution

eynnyd-0.4.1-py3-none-any.whl (62.8 kB view details)

Uploaded Python 3

File details

Details for the file eynnyd-0.4.1.tar.gz.

File metadata

  • Download URL: eynnyd-0.4.1.tar.gz
  • Upload date:
  • Size: 38.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.7.4

File hashes

Hashes for eynnyd-0.4.1.tar.gz
Algorithm Hash digest
SHA256 0756312e9e478153c09435ba089030945035cb7ae8f67c76ca8cec9b13c4f36e
MD5 ed88a1cecff9cf5c5457fe318b839570
BLAKE2b-256 07f01b1c20fab13bc7d8c3e871a167fedf7d9a6efefb3bb29553f52f9da0805d

See more details on using hashes here.

File details

Details for the file eynnyd-0.4.1-py3-none-any.whl.

File metadata

  • Download URL: eynnyd-0.4.1-py3-none-any.whl
  • Upload date:
  • Size: 62.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.7.4

File hashes

Hashes for eynnyd-0.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 cbdff856c7bc16352c47aac5f7fa3de02f05cebbf274e07414c5058eddd9eeb5
MD5 1d68e7cb803196769f4fd05e34f5cb33
BLAKE2b-256 9dd779a6a85b4432c90a8cfa40da0ba87b495f707d531ed0c43faa5f104a02ac

See more details on using hashes here.

Supported by

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