Metadata-Version: 2.4
Name: sprintapi
Version: 0.1.3
Summary: A lightweight FastAPI-based framework that can be used like Spring Boot, with built-in dependency injection and lifecycle management.
Author-email: Lingqiao Zhao <forever.3g@hotmail.com>, Jiaying Zhong <zhongjiaying020@gmail.com>
Project-URL: Homepage, https://github.com/s-zhao-3g/sprintapi
Project-URL: Repository, https://github.com/s-zhao-3g/sprintapi
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.12
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: pydantic>=2
Requires-Dist: fastapi
Requires-Dist: uvicorn
Dynamic: license-file

# 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

```bash
pip install sprintapi
```

## Quick start

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

```python
# 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:

```bash
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

```bash
> 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`.
