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 actual versions of Python (>=3.10).
  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 1747.72
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.0.tar.gz (12.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.0-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: artless_core-0.3.0.tar.gz
  • Upload date:
  • Size: 12.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.0.tar.gz
Algorithm Hash digest
SHA256 5c7d1f01fbafb3a92db4405975c0d892ed107f73c34a6ebcbec0e3bcbb581ea7
MD5 e63e4b4c91c81f8ba411bd425460ba36
BLAKE2b-256 5062f7779a2ec607b5bdc3035d4aa5ac63c70e4a71cb486d99a734c1b05c92ea

See more details on using hashes here.

File details

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

File metadata

  • Download URL: artless_core-0.3.0-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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 956ec3f228d31259158f4cc4768d5d7cdf0a9402866b8aba1a6645179b7fb113
MD5 75147cd118802061c69b71179812a406
BLAKE2b-256 8881f9660e63c4376e51e831a2d8bcc1bb15c10f23c78d21ddeaa3b88d5e83d6

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