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 (editable)
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sprintapi-0.1.1.tar.gz.
File metadata
- Download URL: sprintapi-0.1.1.tar.gz
- Upload date:
- Size: 10.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.29 {"installer":{"name":"uv","version":"0.9.29","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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4d7867325bc9e96f26584e435e7aa7da47348c47cf1055086f96e3f815519bae
|
|
| MD5 |
99aed35a9d5b3e42fd2d15cf44d889ea
|
|
| BLAKE2b-256 |
5b05d695c38f239a3918163e14e8b68b7185c47cf2f723d86506daff2c4efad0
|
File details
Details for the file sprintapi-0.1.1-py3-none-any.whl.
File metadata
- Download URL: sprintapi-0.1.1-py3-none-any.whl
- Upload date:
- Size: 11.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.29 {"installer":{"name":"uv","version":"0.9.29","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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
092a896812e8c63a2e50351f9fd4dd5ea68d50ede6c23e1b98a4c9d4512c99df
|
|
| MD5 |
6ed897ff5e3b007fc51694fab1674202
|
|
| BLAKE2b-256 |
16c6d655187fa44f22c3dff6f5390bd94c6ff39473ace70597e9f491ca4f63a8
|