migrate from flask to quart.
also remove all flaskiness from static file serving. and reference all vendored scripts on the base tempĺate for simplicity.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
from flask import Blueprint
|
||||
from quart import Blueprint
|
||||
|
||||
|
||||
lnurlp_ext: Blueprint = Blueprint("lnurlp", __name__, static_folder="static", template_folder="templates")
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import json
|
||||
from flask import url_for
|
||||
from quart import url_for
|
||||
from lnurl import Lnurl, encode as lnurl_encode
|
||||
from lnurl.types import LnurlPayMetadata
|
||||
from sqlite3 import Row
|
||||
|
||||
@@ -38,7 +38,6 @@
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %} {% block scripts %}
|
||||
<script src="{{ url_for('static', filename='vendor/vue-qrcode@1.0.2/vue-qrcode.min.js') }}"></script>
|
||||
<script>
|
||||
Vue.component(VueQrcode.name, VueQrcode)
|
||||
|
||||
|
||||
@@ -205,7 +205,6 @@
|
||||
</q-dialog>
|
||||
</div>
|
||||
{% endblock %} {% block scripts %} {{ window_vars(user) }}
|
||||
<script src="{{ url_for('static', filename='vendor/vue-qrcode@1.0.2/vue-qrcode.min.js') }}"></script>
|
||||
<script>
|
||||
Vue.component(VueQrcode.name, VueQrcode)
|
||||
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
}
|
||||
</style>
|
||||
{% endblock %} {% block scripts %}
|
||||
<script src="{{ url_for('static', filename='vendor/vue-qrcode@1.0.2/vue-qrcode.min.js') }}"></script>
|
||||
<script>
|
||||
Vue.component(VueQrcode.name, VueQrcode)
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from flask import g, abort, render_template
|
||||
from quart import g, abort, render_template
|
||||
from http import HTTPStatus
|
||||
|
||||
from lnbits.decorators import check_user_exists, validate_uuids
|
||||
@@ -10,19 +10,17 @@ from .crud import get_pay_link
|
||||
@lnurlp_ext.route("/")
|
||||
@validate_uuids(["usr"], required=True)
|
||||
@check_user_exists()
|
||||
def index():
|
||||
return render_template("lnurlp/index.html", user=g.user)
|
||||
async def index():
|
||||
return await render_template("lnurlp/index.html", user=g.user)
|
||||
|
||||
|
||||
@lnurlp_ext.route("/<link_id>")
|
||||
def display(link_id):
|
||||
async def display(link_id):
|
||||
link = get_pay_link(link_id) or abort(HTTPStatus.NOT_FOUND, "Pay link does not exist.")
|
||||
|
||||
return render_template("lnurlp/display.html", link=link)
|
||||
return await render_template("lnurlp/display.html", link=link)
|
||||
|
||||
|
||||
@lnurlp_ext.route("/print/<link_id>")
|
||||
def print_qr(link_id):
|
||||
async def print_qr(link_id):
|
||||
link = get_pay_link(link_id) or abort(HTTPStatus.NOT_FOUND, "Pay link does not exist.")
|
||||
|
||||
return render_template("lnurlp/print_qr.html", link=link)
|
||||
return await render_template("lnurlp/print_qr.html", link=link)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import hashlib
|
||||
from flask import g, jsonify, request, url_for
|
||||
from quart import g, jsonify, request, url_for
|
||||
from http import HTTPStatus
|
||||
from lnurl import LnurlPayResponse, LnurlPayActionResponse
|
||||
from lnurl.exceptions import InvalidUrl as LnurlInvalidUrl
|
||||
@@ -22,7 +22,7 @@ from .crud import (
|
||||
|
||||
@lnurlp_ext.route("/api/v1/links", methods=["GET"])
|
||||
@api_check_wallet_key("invoice")
|
||||
def api_links():
|
||||
async def api_links():
|
||||
wallet_ids = [g.wallet.id]
|
||||
|
||||
if "all_wallets" in request.args:
|
||||
@@ -42,7 +42,7 @@ def api_links():
|
||||
|
||||
@lnurlp_ext.route("/api/v1/links/<link_id>", methods=["GET"])
|
||||
@api_check_wallet_key("invoice")
|
||||
def api_link_retrieve(link_id):
|
||||
async def api_link_retrieve(link_id):
|
||||
link = get_pay_link(link_id)
|
||||
|
||||
if not link:
|
||||
@@ -63,7 +63,7 @@ def api_link_retrieve(link_id):
|
||||
"amount": {"type": "integer", "min": 1, "required": True},
|
||||
}
|
||||
)
|
||||
def api_link_create_or_update(link_id=None):
|
||||
async def api_link_create_or_update(link_id=None):
|
||||
if link_id:
|
||||
link = get_pay_link(link_id)
|
||||
|
||||
@@ -82,7 +82,7 @@ def api_link_create_or_update(link_id=None):
|
||||
|
||||
@lnurlp_ext.route("/api/v1/links/<link_id>", methods=["DELETE"])
|
||||
@api_check_wallet_key("invoice")
|
||||
def api_link_delete(link_id):
|
||||
async def api_link_delete(link_id):
|
||||
link = get_pay_link(link_id)
|
||||
|
||||
if not link:
|
||||
@@ -97,7 +97,7 @@ def api_link_delete(link_id):
|
||||
|
||||
|
||||
@lnurlp_ext.route("/api/v1/lnurl/<link_id>", methods=["GET"])
|
||||
def api_lnurl_response(link_id):
|
||||
async def api_lnurl_response(link_id):
|
||||
link = increment_pay_link(link_id, served_meta=1)
|
||||
if not link:
|
||||
return jsonify({"status": "ERROR", "reason": "LNURL-pay not found."}), HTTPStatus.OK
|
||||
@@ -116,7 +116,7 @@ def api_lnurl_response(link_id):
|
||||
|
||||
|
||||
@lnurlp_ext.route("/api/v1/lnurl/cb/<link_id>", methods=["GET"])
|
||||
def api_lnurl_callback(link_id):
|
||||
async def api_lnurl_callback(link_id):
|
||||
link = increment_pay_link(link_id, served_pr=1)
|
||||
if not link:
|
||||
return jsonify({"status": "ERROR", "reason": "LNURL-pay not found."}), HTTPStatus.OK
|
||||
|
||||
Reference in New Issue
Block a user