A very simple python server framework for REST applications.
pip install kaa-rest-server
Configuration - kaa.json
kaa.json: Specifies server handling.
{
"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.
Initializes Kaa for each http request:
from kaa import KaaServer
class MyServer(KaaServer):
def register_resources(self):
self.kaa.register_resources("resources", "AppResources")
This class define your resources (or routes):
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"
})
Static mode (serve): Starts Kaa server in static mode. Every code change needs restart server manually.
kaa serve
Development mode (dev): Start server that auto restarts on every code change.
kaa dev
By default host is localhost and port is 5321.
You can change them adding host and port on kaa.json file:
{
// ...
"host": "localhost",
"port": 5111,
// ...
}
Or in command line:
kaa serve host:port
For more information, view Documentation.