Skip to main content

A lightweight FastAPI-based framework that can be used like Spring Boot, with built-in dependency injection and lifecycle management.

Project description

SprintAPI Framework

A lightweight FastAPI-based framework that can be used like Spring Boot, with built-in dependency injection and lifecycle management.

Core features

  • Configuration via environment variables over config file, which is friendly to containerized deployments and 12-factor apps;
  • Built-in dependency injection, which enables IoC and better handles dependency management for larger apps;
  • Controller-based API design, which is more intuitive for developers coming from other languages;
  • Lifecycle hooks called on same event loop as the server, and are called in dependency order;

Requirements

  • Python 3.12+

Install

pip install sprintapi

Quick start

Below is a minimal example of a controller exposing a single GET endpoint.

# main.py

from sprintapi import SprintApiServer, api_route, get_mapping, Controller


@api_route('/simple')
class SimpleController(Controller):
    """A minimal controller exposing a single GET endpoint."""

    @get_mapping('hello')
    async def hello(self):
        """Return a simple greeting."""
        return 'Hello, World!'


def main():
    # Create and run the server; pass `port=8000` to change the default.
    server = SprintApiServer()
    server.run()


if __name__ == '__main__':
    main()

Run it:

python main.py

This runs a web server listening on http://localhost:80. Then open http://localhost/simple/hello in your browser, you will see:

Hello, World!

With Dependency Injection

> cd examples/with-di
> export APP_NAME="My Demo"
> python main.py

Then open http://localhost/app/name in your browser and you will see:

This app is My Demo

License

MIT. See LICENSE.

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

sprintapi-0.1.3.tar.gz (724.1 kB view details)

Uploaded Source

Built Distribution

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

sprintapi-0.1.3-py3-none-any.whl (728.1 kB view details)

Uploaded Python 3

File details

Details for the file sprintapi-0.1.3.tar.gz.

File metadata

  • Download URL: sprintapi-0.1.3.tar.gz
  • Upload date:
  • Size: 724.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.6 {"installer":{"name":"uv","version":"0.10.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for sprintapi-0.1.3.tar.gz
Algorithm Hash digest
SHA256 ef5d66e24f1916e329a2f8fca4fcf3d3f8034983c81148a770050990780b861c
MD5 dd1af047d58e53503d601918b36ba658
BLAKE2b-256 ab724264e0adc61602fa95568c7f368863e0f6d113a1fd7f40035e738a3401f5

See more details on using hashes here.

File details

Details for the file sprintapi-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: sprintapi-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 728.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.6 {"installer":{"name":"uv","version":"0.10.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for sprintapi-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 3c2332cdef66e0447bf4b279cb92c8780f98ed70d32ea9cbd687faacc8fda7c3
MD5 c515baeb9fe9b14a043956bb4a31578c
BLAKE2b-256 36a33760e322b7af30d24c6c7eb9182408175246555a5f2eb72f6c0555cfdfcd

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