lnbits-legend/lnbits/extensions/example/views_api.py

41 lines
967 B
Python
Raw Normal View History

2020-04-03 22:28:25 +02:00
# views_api.py is for you API endpoints that could be hit by another service
2020-02-20 00:21:01 +01:00
2020-04-03 22:28:25 +02:00
# add your dependencies here
2020-02-20 00:21:01 +01:00
2020-04-03 22:28:25 +02:00
# import json
# import httpx
# (use httpx just like requests, except instead of response.ok there's only the
# response.is_error that is its inverse)
2020-04-03 22:28:25 +02:00
from quart import jsonify
from http import HTTPStatus
2020-04-03 22:28:25 +02:00
from . import example_ext
2020-02-20 00:21:01 +01:00
2020-04-03 22:28:25 +02:00
# add your endpoints here
2020-08-31 04:19:43 +02:00
2020-04-03 22:28:25 +02:00
@example_ext.route("/api/v1/tools", methods=["GET"])
async def api_example():
2020-02-20 00:21:01 +01:00
"""Try to add descriptions for others."""
2020-04-03 22:28:25 +02:00
tools = [
2020-11-22 03:23:11 +01:00
{
2020-12-02 11:45:12 +01:00
"name": "Quart",
"url": "https://pgjones.gitlab.io/quart/",
2020-11-22 03:23:11 +01:00
"language": "Python",
},
{
"name": "Vue.js",
"url": "https://vuejs.org/",
"language": "JavaScript",
},
{
"name": "Quasar Framework",
"url": "https://quasar.dev/",
"language": "JavaScript",
},
2020-04-03 22:28:25 +02:00
]
return jsonify(tools), HTTPStatus.OK