mirror of
https://github.com/planetmint/planetmint.git
synced 2025-11-24 22:45:44 +00:00
* added api to get the latest block /api/v1/blocks/latest Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * git fixed flake8 whitespace warnings Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * fixed flake8 warnings: removed too many newline Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * added missing deps in the testing docker files Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * install meson prior to the rest to have it availabe and fix the issue of missing depenceny declarations within zenroom Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * added missing ninja dependency Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * fixed zenroom dependency Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com>
50 lines
1.3 KiB
Python
50 lines
1.3 KiB
Python
# Copyright © 2020 Interplanetary Database Association e.V.,
|
|
# Planetmint and IPDB software contributors.
|
|
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
|
# Code is Apache-2.0 and docs are CC-BY-4.0
|
|
|
|
"""API routes definition"""
|
|
from flask_restful import Api
|
|
from planetmint.web.views import (
|
|
assets,
|
|
metadata,
|
|
blocks,
|
|
info,
|
|
transactions as tx,
|
|
outputs,
|
|
validators,
|
|
)
|
|
|
|
|
|
def add_routes(app):
|
|
"""Add the routes to an app"""
|
|
for (prefix, routes) in API_SECTIONS:
|
|
api = Api(app, prefix=prefix)
|
|
for ((pattern, resource, *args), kwargs) in routes:
|
|
kwargs.setdefault('strict_slashes', False)
|
|
api.add_resource(resource, pattern, *args, **kwargs)
|
|
|
|
|
|
def r(*args, **kwargs):
|
|
return (args, kwargs)
|
|
|
|
|
|
ROUTES_API_V1 = [
|
|
r('/', info.ApiV1Index),
|
|
r('assets/', assets.AssetListApi),
|
|
r('metadata/', metadata.MetadataApi),
|
|
r('blocks/<int:block_id>', blocks.BlockApi),
|
|
r('blocks/latest', blocks.LatestBlock),
|
|
r('blocks/', blocks.BlockListApi),
|
|
r('transactions/<string:tx_id>', tx.TransactionApi),
|
|
r('transactions', tx.TransactionListApi),
|
|
r('outputs/', outputs.OutputListApi),
|
|
r('validators/', validators.ValidatorsApi),
|
|
]
|
|
|
|
|
|
API_SECTIONS = [
|
|
(None, [r('/', info.RootIndex)]),
|
|
('/api/v1/', ROUTES_API_V1),
|
|
]
|