From 705a12829f08616d3d1bf981206c8e03069eed07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?dni=20=E2=9A=A1?= Date: Tue, 16 Apr 2024 08:29:25 +0200 Subject: [PATCH] fixup! --- models.py | 9 +++++---- pyproject.toml | 1 + views.py | 4 ++-- views_api.py | 6 ++++-- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/models.py b/models.py index bfeb751..136f074 100644 --- a/models.py +++ b/models.py @@ -1,5 +1,6 @@ -# from pydantic import BaseModel +from pydantic import BaseModel -# class Example(BaseModel): -# id: str -# wallet: str + +class Example(BaseModel): + id: str + wallet: str diff --git a/pyproject.toml b/pyproject.toml index 1c4a9ba..f2ace0c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -25,6 +25,7 @@ module = [ "lnbits.*", "loguru.*", "fastapi.*", + "pydantic.*", ] ignore_missing_imports = "True" diff --git a/views.py b/views.py index 938e505..17f9248 100644 --- a/views.py +++ b/views.py @@ -1,8 +1,8 @@ from fastapi import APIRouter, Depends, Request +from fastapi.responses import HTMLResponse from lnbits.core.models import User from lnbits.decorators import check_user_exists from lnbits.helpers import template_renderer -from starlette.responses import HTMLResponse example_ext_generic = APIRouter() @@ -13,5 +13,5 @@ async def index( user: User = Depends(check_user_exists), ): return template_renderer(["example/templates"]).TemplateResponse( - "example/index.html", {"request": request, "user": user.dict()} + request, "example/index.html", {"user": user.dict()} ) diff --git a/views_api.py b/views_api.py index c6e3357..e18daa1 100644 --- a/views_api.py +++ b/views_api.py @@ -1,11 +1,13 @@ from fastapi import APIRouter +from .models import Example + # views_api.py is for you API endpoints that could be hit by another service example_ext_api = APIRouter() @example_ext_api.get("/api/v1/test/{test_data}") -async def api_example(test_data): +async def api_example(test_data: str) -> Example: # Do some python things and return the data - return test_data + return Example(id="1", wallet=test_data)