Skip to main content

superfunctions-flask

Flask adapter for superfunctions.http

Location: packages/python-flask/
Package: superfunctions-flask
Import: from superfunctions_flask import create_blueprint

Installation

pip install superfunctions-flask

Usage

Option 1: Create Blueprint from Routes

from flask import Flask
from superfunctions.http import Route, HttpMethod, Response, NotFoundError
from superfunctions_flask import create_blueprint

app = Flask(__name__)

# Define handlers using superfunctions abstractions
async def get_user(request, context):
    user_id = context.params["id"]
    
    # Your logic here
    user = await db.find_one(...)
    if not user:
        raise NotFoundError(f"User {user_id} not found")
    
    return Response(status=200, body=user)

async def create_user(request, context):
    data = await request.json()
    user = await db.create(...)
    return Response(status=201, body=user)

# Create blueprint from routes
routes = [
    Route(method=HttpMethod.GET, path="/users/<id>", handler=get_user),
    Route(method=HttpMethod.POST, path="/users", handler=create_user),
]

blueprint = create_blueprint(routes, name="api", url_prefix="/api/v1")
app.register_blueprint(blueprint)

Option 2: Convert Individual Handlers

from flask import Flask
from superfunctions_flask import to_flask_handler
from superfunctions.http import Response

app = Flask(__name__)

async def get_user(request, context):
    return Response(status=200, body={"id": context.params["id"]})

@app.route("/users/<id>")
def route(id):
    handler = to_flask_handler(get_user)
    return handler(id=id)

Features

  • ✅ Automatic request/response conversion
  • ✅ HTTP error handling
  • ✅ Path parameters
  • ✅ Query parameters
  • ✅ Headers
  • ✅ JSON body parsing
  • ✅ Blueprint support

Benefits

Write framework-agnostic handlers that work across:

  • Flask
  • FastAPI (with superfunctions-fastapi)

Example with authfn

from flask import Flask
from superfunctions_flask import create_blueprint
from superfunctions.http import Route, HttpMethod, Response, UnauthorizedError
from authfn import create_authfn, AuthFnConfig

app = Flask(__name__)
auth = create_authfn(AuthFnConfig(database=adapter))

async def get_protected_resource(request, context):
    # Authenticate using authfn
    auth_header = context.headers.get("authorization")
    if not auth_header:
        raise UnauthorizedError("Missing authorization header")
    
    session = await auth.provider.authenticate(request)
    if not session:
        raise UnauthorizedError("Invalid credentials")
    
    return Response(status=200, body={"message": "Protected resource", "user": session.keyId})

routes = [
    Route(method=HttpMethod.GET, path="/protected", handler=get_protected_resource),
]

blueprint = create_blueprint(routes)
app.register_blueprint(blueprint)

License

MIT

Metadata

Release files for superfunctions-flask 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for superfunctions-flask 0.1.1
File Size Uploaded Provenance Actions
superfunctions_flask-0.1.1.tar.gz 7.8 kB With provenance Details for superfunctions_flask-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for superfunctions-flask 0.1.1
File Interpreter ABI Platform Actions
superfunctions_flask-0.1.1-py3-none-any.whl Python 3 none any Details for superfunctions_flask-0.1.1-py3-none-any.whl

Total release size: 13.4 kB

Release files / superfunctions_flask-0.1.1.tar.gz

Download URL superfunctions_flask-0.1.1.tar.gz
Size 7.8 kB
Tags Source
SHA-256 checksum
How to use checksums
4383fd687d403ec81186ff1e50a93a7ec6862299116bdb207e1a80b3448fc657
BLAKE2b-256 checksum
How to use checksums
4e39934f8dbed14e7b645f8599021be1086edb6022eace65ef4c564b5c8e061a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.

Transparency log

Release files / superfunctions_flask-0.1.1-py3-none-any.whl

Download URL superfunctions_flask-0.1.1-py3-none-any.whl
Size 5.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c54788413707126eb17b5f6360b7ae679b9e4f2caac430e660a214e782570c56
BLAKE2b-256 checksum
How to use checksums
c2ca8bce7168fcce93ca66f1ed1c2cac068d04dc3ba84bd4a3f887ee56cad1c3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.

Transparency log

Security for superfunctions-flask 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for superfunctions_flask-0.1.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page