Skip to main content

The artless and minimalistic web library for creating small applications or APIs.

Project description

artless-core

PyPI Version Development Status PyPI - Python Version Downloads PyPI - License

The artless and minimalistic library for creating small web applications or APIs.

Motivation

An extremely minimalistic framework was needed to create the same minimalistic applications. Those "micro" frameworks like Flask, Pyramid, CherryPie, etc - turned out to be not micro at all). Even a single-module Bottle turned out to be a "monster" of 4 thousand LOC and supporting compatibility with version 2.7.

Therefore, it was decided to sketch out our own simple, minimally necessary implementation of the WSGI and ASGI library for creating small/simple web app.

Main principles

  1. Artless, fast and small (less then 500 LOC) single-module package.
  2. No third party dependencies (standart library only).
  3. Support only modern versions of Python (>=3.11).
  4. Mostly pure functions without side effects.
  5. Interfaces with type annotations.
  6. Comprehensive documentation with examples of use.
  7. Full test coverage.

Limitations

  • No WebSocket support.
  • No Cookies support.
  • No multipart/form-data support.
  • No builtin models, ORM, template engine, form serialisation and other.
  • No built-in protections, such as: CSRF, XSS, clickjacking and other.

Installation

$ pip install artless-core

Getting Started

WSGI application

from artless import WSGIApp, Request, Response, plain


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


def create_application() -> WSGIApp:
    app = WSGIApp()
    app.set_routes([("GET", r"^/hello/(?P<name>\w+)$", say_hello)])
    return app


application = create_application()

Run it with eny asgi server, uvicorn for example:

$ gunicorn app
[2025-01-11 16:34:19 +0300] [62111] [INFO] Starting gunicorn 23.0.0
[2025-01-11 16:34:19 +0300] [62111] [INFO] Listening at: http://127.0.0.1:8000 (62111)
[2025-01-11 16:34:19 +0300] [62111] [INFO] Using worker: sync
[2025-01-11 16:34:19 +0300] [62155] [INFO] Booting worker with pid: 62155

Check it:

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

Need more? See documentation and wsgi examples.

ASGI application

from artless import ASGIApp, Request, Response, plain


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


def create_application() -> ASGIApp:
    app = ASGIApp()
    app.set_routes([("GET", r"^/hello/(?P<name>\w+)$", say_hello)])
    return app


application = create_application()

Run it:

$ uvicorn app:application
INFO:     Started server process [62683]
INFO:     Waiting for application startup.
INFO:     ASGI 'lifespan' protocol appears unsupported.
INFO:     Application startup complete.
INFO:     Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)

Check it:

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

Need more? See documentation and asgi examples.

Benchmarks results

See more details in benchmarks/README.md.

WSGI (single worker)

Framework RPS (mean)
Falcon 1794.59
Artless 1782.67
Bottle 1646.37
Flask 1468.70
Django 1359.61

WSGI (multiple workers)

Framework RPS (mean)
Falcon 3437.07
Artless 3414.04
Bottle 3331.41
Flask 2974.08
Django 1701.12

ASGI (single worker)

Framework RPS (mean)
Blacksheep 3456.86
Falcon 3338.41
Artless 3320.35
FastAPI 2191.76
Django 1160.94
Flask 777.81

ASGI multiple workers plaintext response

Framework RPS (mean)
Falcon 5393.27
Blacksheep 5382.32
Artless 5332.50
FastAPI 3594.12
Django 2050.55
Flask 1627.59

Roadmap

  • Add Async/ASGI support.
  • Add plugins support.
  • Add test client.
  • Add benchmarks.
  • Add more examples.
  • Add Sphinx doc.

Related projects

  • artless-template - the artless and small template library for server-side rendering.

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_core-0.3.1.tar.gz (13.7 kB view details)

Uploaded Source

Built Distribution

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

artless_core-0.3.1-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

File details

Details for the file artless_core-0.3.1.tar.gz.

File metadata

  • Download URL: artless_core-0.3.1.tar.gz
  • Upload date:
  • Size: 13.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for artless_core-0.3.1.tar.gz
Algorithm Hash digest
SHA256 0a3a282b27e75c2e36f1ae82ad1a64124b1c65340a27278fd2f3dc9a581a073f
MD5 a57c75a2e24ca57494cd58b5f69f656d
BLAKE2b-256 45e5b9ca3b2ba23e5e2c20f686495061898ab67331b50e7065d6c2ff6e0fac0c

See more details on using hashes here.

File details

Details for the file artless_core-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: artless_core-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 8.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for artless_core-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0f11205a26f0c19fe467d0faf298bdfcf3b7021b56d7223ba16ead2801d84ecf
MD5 54c375d0f65958070cae6cfb164b1d1c
BLAKE2b-256 06f8212d7243b0cac2d70e65e2d1d8a744a248f1b61b3b683bf6a335bd14ad23

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