Skip to main content

API Tackle - Simple Python REST API Framework

Project description

Simple Python REST API Framework …

Quickstart

See https://github.com/praekelt/api-tackle-example-app for an example of how to build an API-Tackle application.

A simple wsgi example application looks like:

""" WSGI Flask App for production hosting with e.g.: gunicorn --bind 0.0.0.0:80 -w 1 -t 120 wsgi """
import os
import logging

from tackle.flask_utils import create_flask_app  # noqa
from tackle.flask_utils import setup_logging  # noqa
from tackle.prometheus_utils import create_prometheus_server  # noqa
from tackle.rest_api.wrapper_util import add_auth_token  # noqa

from my_api.rest_api import get_path  # noqa

create_prometheus_server(9100)

setup_logging(requested_logging_path='~/.tackle/logs',
              include_prometheus=True)

flask_app = create_flask_app(specification_dir=get_path() + '',
                             add_api=True,
                             swagger_ui=True,
                             database_url='sqlite://',
                             database_create_tables=True,
                             debug=False)

# === Add some auth tokens to the DB ===
add_auth_token('tackleb6-12dd-4104-a7b6-f7d369ff5fec', "Default token e.g. internal hosting.")
# === ===

logging.info(f"rest_wsgi_app.py: __name__ == {__name__}")
application = flask_app.app

if __name__ == "__main__":
    logging.info(f"rest_wsgi_app.py: __main__ Starting Flask app in Python __main__ .")
    flask_app.run()

Building your own API

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

api_tackle-0.2.tar.gz (17.0 kB view hashes)

Uploaded Source

Built Distribution

api_tackle-0.2-py3-none-any.whl (24.2 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page