Skip to main content

The artless and ultralight web framework for building minimal APIs and apps.

Project description

artless-core

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

The artless and ultralight web framework for building minimal APIs and apps.

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 building simple APIs and apps.

Why artless-core?

  • 🪶 Tiny: Single module, no dependencies, less then 500 LOC
  • ⚡ Fast: Optimized pure Python with async support
  • 🧩 Simple: Intuitive API with type hints
  • ✅ Tested: 100% coverage
  • 🐍 Modern: Python 3.11+ only

Quickstart

Installation

$ pip install artless-core

WSGI Example

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 with Gunicorn:

$ 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 Example

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 with Uvicorn:

$ 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.

Limitations

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

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 Sphinx doc.
  • Add benchmarks.
  • Add Async/ASGI support.
  • Add test clients (for WSGI and ASGI).
  • Add plugins support.
  • Add middlewares support.
  • Add more complex examples.

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.2.tar.gz (13.6 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.2-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: artless_core-0.3.2.tar.gz
  • Upload date:
  • Size: 13.6 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.2.tar.gz
Algorithm Hash digest
SHA256 d69882ad12a46c3a77b6acc2ec399ca91ea7f90736060be5fe02693969549251
MD5 d4e6d5ec869af5203c935655cd3bf417
BLAKE2b-256 b710d844281ef553dad1088de80d5736b2c26ba42b2ab63feb6d0eaea79ca071

See more details on using hashes here.

File details

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

File metadata

  • Download URL: artless_core-0.3.2-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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 71d7419f10858a51748bd66a82fd30ee5959859ce52e0614a17a0872b9935d79
MD5 f87bc9dee9dca5ecd51449c8fefd52bd
BLAKE2b-256 1f212ffbcb72b6d08209986f0f0011cb49e6869bbe7d0718b5bed28840005044

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