Skip to main content

Artless and minimalistic web framework without dependencies, working over WSGI.

Project description

artless-framework

Downloads PyPI - Python Version PyPI Version

The artless and minimalistic web framework without dependencies, working over WSGI.

Main principles

  1. Artless, fast and small (less then 1000 LOC) WSGI-framework.
  2. No third party dependencies (standart library only).
  3. Support only modern versions of Python (>=3.10).
  4. Integrated with most popular WSGI-servers.
  5. Mostly pure functions without side effects.
  6. Interfaces with type annotations.
  7. Comprehensive documentation with examples of use.
  8. Full test coverage.

Limitations

  • No built-in support for working with Cookies.
  • Requests with multipart/form-data content-type are not supported.
  • No built-in protections, such as: CSRF, XSS, clickjacking and other attack techniques.

Usages

from os import getenv

from artless import App, Request, Response, ResponseFactory


def say_hello(request: Request, username: str) -> Response:
    return ResponseFactory.plain(f"Hello, {username}!")


def create_application(config) -> App:
    app = App(config)
    app.set_routes((("GET", r"^/hello/(?P<username>\w+)/$", say_hello),))
    return app


config = {
    "DEBUG": True,
}

application = create_application(config)

if __name__ == "__main__":
    from wsgiref.simple_server import make_server

    host = getenv("HOST", "127.0.0.1")
    port = int(getenv("PORT", 8000))

    with make_server(host, port, application) as httpd:
        print(f"Started WSGI server on {host}:{port}")
        httpd.serve_forever()

Run it:

$ python3 app.py
Started WSGI server on 127.0.0.1:8000

Check it:

$ curl http://127.0.0.1:8000/hello/Peter/
Hello, Peter!

See more examples.

Roadmap

  • Add plugin support.
  • Add cookies support.
  • Add async interface.
  • Add multipart/form-data support.
  • Add test client.
  • Add benchmarks.
  • Add more examples.

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

artless_framework-0.1.0.tar.gz (10.6 kB view hashes)

Uploaded Source

Built Distribution

artless_framework-0.1.0-py3-none-any.whl (7.9 kB view hashes)

Uploaded Python 3

Supported by

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