Skip to main content

Simple, efficient, intuitive API Framework

Project description

This is sample template to create a quick Python Falcon API application. It uses a schema defined in the resource for the route path and OpenAPI documentation. The base application will handle creating the routes and documentation automatically at runtime.

You define a resource and the documentation will be auto-generated at startup using the docstrings.

from reliqua.resources.base import Resource
from reliqua import status_codes as status


class User(Resource):

    __routes__ = [
        '/users/{id}',
    ]

    phone = phone

    def on_get(self, req, resp, id=None):
        """
        Retrieve a user. This value
        is awesome

        :param str id:       [in=path, required] User ID
        :param str email:    [in=query] User Email
        :param str phone:    [in=query, enum] Phone Numbers

        :response 200:
        :response 400:

        :return json:
        """
        try:
            resp.media = users[int(id)]
        except IndexError:
            resp.status = status.HTTP_404

    def on_delete(self, req, resp, id=None):
        try:
            users.pop(int(id))
            resp.media = {'success': True}
        except IndexError
            resp.status = status.HTTP_400

This will create the /users/{id} endpoint and corresponding API documentation. The OpenAPI documentation and swagger.json will be dynamically generate at application startup. The OpenAPI ui will be available at:

http://<api-url>/docs/

and the swagger.json file located at:

http://<api-url>/docs/swagger.json

To create an application, you import the application template.

from reliqua.app import Application

    
app = Application(
    bind='0.0.0.0:8000',
    proxy_api_url = 'http://example.com/api',
    workers=1,
    resource_path='/var/www/html/resources'
)
app.run()
Where:

bind:           Address and port to listen for requests. [host:port]
proxy_api_url:  The URL to the API when being used with a proxy, like nginx. If not supplied,
                then the bind address is used.
workers:        Number of worker threads to start.
resource_path:  This is where your python resource files are located.

Refer to the example application for more examples. You can install the library and example application

python setup.py install

You can execute the example application

$ reliqua-example 

From here the openapi-ui will be available at

http://localhost:8000/docs/

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

reliqua-0.0.6.tar.gz (25.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

reliqua-0.0.6-py3-none-any.whl (28.2 kB view details)

Uploaded Python 3

File details

Details for the file reliqua-0.0.6.tar.gz.

File metadata

  • Download URL: reliqua-0.0.6.tar.gz
  • Upload date:
  • Size: 25.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for reliqua-0.0.6.tar.gz
Algorithm Hash digest
SHA256 517660b644800869d7751e06938418e1364b85f3f88db1e21a9132df32eb6697
MD5 fbd43cc364aa4550d243ad7c66c57c4d
BLAKE2b-256 251bdead5ff06b2eef7309e718e5f0b3d7d95ad306af49165775ff3c97958e77

See more details on using hashes here.

Provenance

The following attestation bundles were made for reliqua-0.0.6.tar.gz:

Publisher: publish-pypi.yml on tmeiczin/reliqua

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file reliqua-0.0.6-py3-none-any.whl.

File metadata

  • Download URL: reliqua-0.0.6-py3-none-any.whl
  • Upload date:
  • Size: 28.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for reliqua-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 aa4fe134ea81e0832f7ace172aec6662a26966e383341b387e4fa9192e5e7447
MD5 bcbde7f15a0904c9347aad63365efebf
BLAKE2b-256 b7e5b2d375ee9b4696c6a67ec75634cc13d073ceb888a9155c8766a115f72ef2

See more details on using hashes here.

Provenance

The following attestation bundles were made for reliqua-0.0.6-py3-none-any.whl:

Publisher: publish-pypi.yml on tmeiczin/reliqua

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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