Metadata-Version: 2.1
Name: kaa-rest-server
Version: 0.3.3
Summary: A very simple python REST server
Author-email: Francesc d'Assís Requesens i Roca <francesc.requesens@proton.me>
License: MIT License
        
        Copyright (c) 2020 elpeix
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://github.com/elpeix/kaa
Project-URL: Bug Reports, https://github.com/elpeix/kaa
Project-URL: Source, https://github.com/elpeix/kaa
Keywords: server,development
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Topic :: Software Development :: Build Tools
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE

# Kaa REST Server

A very simple python server framework for REST applications.

## Install

```console
pip install kaa-rest-server
```

## [Configuration](docs/configuration.md) - kaa.json

**kaa.json**: Specifies server handling.

```json
{
  "name": "My Server",
  "version": "1.0.0",
  "server": "server.MyServer",
  "debug": false,
  "enableCors": false,
  "developmentPolling": {
    "enabled": true,
    "intervalSeconds": 1,
    "include": [".", "src", "*.py"],
    "exclude": [
      "docs",
      "tests",
      "__pycache__",
      "*.md"
    ]
  }
}
```

See [Configuration](docs/configuration.md).

### Definitions (deprecated)

See [Legacy Documentation](docs/legacy.md)

## Main classes

### server.py

Initializes Kaa for each http request:

```python
from kaa import KaaServer


class MyServer(KaaServer):

    def register_resources(self):
        self.kaa.register_resources("resources", "AppResources")
```

### resources.py

This class define your resources (or routes):

```python
from kaa import GET, PATH, Resources, Response, Status


class AppResources(Resources):

    @GET
    @PATH("/")
    def basic_resource(self, **params):
        return Response(Status.OK).json({
            "message": "your response"
        })
```

## Starting server

**Static mode** (serve): Starts Kaa server in static mode. Every code change
needs restart server manually.

```console
kaa serve
```

**Development mode** (dev): Start server that auto restarts on every code change.

```console
kaa dev
```

## Custom host and port

By default host is localhost and port is 5321.

You can change them adding host and port on kaa.json file:

```jsonc
{
  // ...
  "host": "localhost",
  "port": 5111,
  // ...
}
```

Or in command line:

```console
kaa serve host:port
```

## More

For more information, [view Documentation](docs/README.md).
