A very simple REST server
Project description
Kaa
A very simple python server framework for REST applications.
Starting
Requirements
- pyYaml for OpenApi output
Install
pip install kaa-rest-server
Main files
Definition
Requires file definition.py at the top of the project:
import logging
NAME = 'Simple kaa Server' # Your project name
VERSION = 'v1.0' # Version
SERVER = 'server.Server' # Module and main class
LOG = logging.getLogger()
DEBUG = True
ENABLE_CORS = False
Application file
Requires a simple file to start server (app.py)
import importlib
from kaa.cli import Cli, Server
# For WSGI application
def application(env, start_response):
return Server().serve(env, start_response)
# For development
if __name__ == "__main__":
cli = Cli()
cli.execute()
Main classes
(file server.py)
This class initializes Kaa for each http request
from kaa import Kaa, KaaServer
class Server(KaaServer):
def register_resources(self):
self.kaa.register_resources('app', 'AppResources')
This class define your resources
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
$ python kaa.py serve
By default host is 127.0.0.1 and port is 8086
Start with diferent host and port:
$ python kaa.py serve host:port
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
kaa-rest-server-0.2.0.tar.gz
(10.0 kB
view hashes)
Built Distribution
Close
Hashes for kaa_rest_server-0.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c2b21a0837f56d129d2c219c7066fbc8e814f192ee1654c2f37dfea02420b96a |
|
MD5 | 76fa15fdfd8dbbb5019171316eda5863 |
|
BLAKE2b-256 | 3f702061484b8c3cc6e8a175e062f128170ad5f3584fee3d0f830533f5ce2bb8 |