Skip to main content

Execute function with FastAPI features.

Project description

fastexec

Execute function with FastAPI features.

Summary

Fastexec allows you to execute a function as if it were a FastAPI endpoint, leveraging FastAPI's dependency injection system. This is particularly useful for testing and debugging routes and dependencies.

Quick Start

import asyncio

import fastapi

from fastexec import FastExec


def my_dependency(request: fastapi.Request):
    return request.headers.get("Authorization")


async def my_endpoint(auth: str = fastapi.Depends(my_dependency)):
    return {"auth": auth}


async def main():
    app = FastExec(call=my_endpoint)
    result = await app.exec(headers={"Authorization": "Bearer your_token_here"})
    print(result)  # Output: {'auth': 'Bearer your_token_here'}


asyncio.run(main())

Installation

pip install fastexec

Usage

1. Define your dependencies and endpoint function:

import fastapi
from fastexec import FastExec

# ... your dependencies and endpoint function

2. Create a FastExec instance:

app = FastExec(call=your_endpoint_function)

3. Execute the function:

result = await app.exec(
    query_params=your_query_params,
    headers=your_headers,
    body=your_body,
)

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

fastexec-0.3.0.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

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

fastexec-0.3.0-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: fastexec-0.3.0.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.5 CPython/3.12.8 Darwin/24.1.0

File hashes

Hashes for fastexec-0.3.0.tar.gz
Algorithm Hash digest
SHA256 69eea2fbceb3df4f28cc71afdbba9595a0db9ba97c2686e8f4703f2258e8d6fc
MD5 85fbac763aecfe16e48155dd23f4f1e8
BLAKE2b-256 b919e0bbfa11bf53ebb3439626cf82739099eda4e98d0519264fdf49dd695067

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fastexec-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 6.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.5 CPython/3.12.8 Darwin/24.1.0

File hashes

Hashes for fastexec-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7af7da4a166d1d65037e2c452b4c213f035d6c6ba97b84d11fb727671dd4c9ac
MD5 8873bda646ddb28e38280a2da6421282
BLAKE2b-256 59bc6999bde70f645486bb34ac02391264af2402fc636e044c2058e155a492c0

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