From 8cdbd02a77d68dc5f51645972adf15b25176dfc5 Mon Sep 17 00:00:00 2001 From: Tiago vasconcelos Date: Wed, 1 Dec 2021 11:27:43 +0000 Subject: [PATCH] htmlresponse --- lnbits/core/views/public_api.py | 3 ++- lnbits/extensions/lnaddress/lnurl.py | 7 ++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lnbits/core/views/public_api.py b/lnbits/core/views/public_api.py index 0f5c74e3..f8b48ecc 100644 --- a/lnbits/core/views/public_api.py +++ b/lnbits/core/views/public_api.py @@ -5,6 +5,7 @@ from urllib.parse import urlparse from fastapi import HTTPException from starlette.requests import Request +from starlette.responses import HTMLResponse from lnbits import bolt11 @@ -13,7 +14,7 @@ from ..crud import get_standalone_payment from ..tasks import api_invoice_listeners -@core_app.get("/.well-known/lnurlp/{username}") +@core_app.get("/.well-known/lnurlp/{username}", response_class=HTMLResponse) async def lnaddress(username: str, request: Request): from lnbits.extensions.lnaddress.lnurl import lnurl_response diff --git a/lnbits/extensions/lnaddress/lnurl.py b/lnbits/extensions/lnaddress/lnurl.py index 77eee507..ba3a53ea 100644 --- a/lnbits/extensions/lnaddress/lnurl.py +++ b/lnbits/extensions/lnaddress/lnurl.py @@ -9,6 +9,7 @@ from lnurl import ( # type: ignore LnurlPayResponse, ) from starlette.requests import Request +from starlette.responses import HTMLResponse from . import lnaddress_ext from .crud import get_address, get_address_by_username, get_domain @@ -35,10 +36,10 @@ async def lnurl_response(username: str, domain: str, request: Request): metadata=await address.lnurlpay_metadata(domain=domain), ) print("RESP", resp.dict()) - return resp + return resp.dict() -@lnaddress_ext.get("/lnurl/cb/{address_id}", name="lnaddress.lnurl_callback") +@lnaddress_ext.get("/lnurl/cb/{address_id}", name="lnaddress.lnurl_callback", response_class=HTMLResponse) async def lnurl_callback(address_id, amount: int = Query(...)): print("PING") address = await get_address(address_id) @@ -82,4 +83,4 @@ async def lnurl_callback(address_id, amount: int = Query(...)): resp = LnurlPayActionResponse(pr=r["payment_request"], routes=[]) - return resp + return resp.dict()