Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
test: receive value from button
Signed-off-by: Alexander Piskun <bigcat88@icloud.com>
  • Loading branch information
bigcat88 committed Nov 30, 2023
commit abd72f77d968b610a88064141cafcf1dbfbc8fd3
13 changes: 10 additions & 3 deletions examples/as_app/ui_example/lib/main.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
"""Example with which we test UI elements."""

import random
import typing
from contextlib import asynccontextmanager

from fastapi import Depends, FastAPI, responses
from pydantic import BaseModel

from nc_py_api import NextcloudApp
from nc_py_api.ex_app import nc_app, run_app, set_handlers
Expand All @@ -23,12 +25,17 @@ def enabled_handler(enabled: bool, _nc: NextcloudApp) -> str:
return ""


class Button1Format(BaseModel):
initial_value: str


@APP.post("/verify_initial_value")
def verify_initial_value(
async def verify_initial_value(
_nc: typing.Annotated[NextcloudApp, Depends(nc_app)],
input1: Button1Format,
):
# print(param)
return responses.JSONResponse(content={"initial_value": "Button was pressed"}, status_code=200)
print("Old value: ", input1.initial_value)
return responses.JSONResponse(content={"initial_value": str(random.randint(0, 100))}, status_code=200)


if __name__ == "__main__":
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ extend-ignore = ["D107", "D105", "D203", "D213", "D401", "I001", "RUF100"]
[tool.ruff.extend-per-file-ignores]
"benchmarks/**/*.py" = ["D"]
"docs/**/*.py" = ["D"]
"examples/**/*.py" = ["D", "S106"]
"examples/**/*.py" = ["D", "S106", "S311"]
"tests/**/*.py" = ["D", "E402", "S", "UP"]

[tool.ruff.mccabe]
Expand Down