webapp
Webapp router.
This module contains the web routes for the tool inventory application. It provides endpoints for creating, reading, updating, and deleting tools, as well as updating tool quantities.
web_create_tool
async
¶
web_create_tool(name: Annotated[str, Form()], description: Annotated[str, Form()], quantity: Annotated[int, Form()]) -> RedirectResponse
Create a new tool.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
Annotated[str, Form()]
|
The name of the tool. |
required |
description
|
Annotated[str, Form()]
|
The description of the tool. |
required |
quantity
|
Annotated[int, Form()]
|
The quantity of the tool. |
required |
Returns:
| Type | Description |
|---|---|
RedirectResponse
|
A redirect response to the home page. |
Source code in src/tool_inventory/routers/webapp.py
web_create_tool_form
async
¶
Render the tool creation form.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
Request
|
The request object. |
required |
Returns:
| Type | Description |
|---|---|
HTMLResponse
|
An HTML response with the tool creation form. |
Source code in src/tool_inventory/routers/webapp.py
web_delete_tool
async
¶
Delete a tool.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
Request
|
The request object. |
required |
tool_id
|
UUID
|
The UUID of the tool to delete. |
required |
Returns:
| Type | Description |
|---|---|
HTMLResponse
|
A script to delete the tool. |
Source code in src/tool_inventory/routers/webapp.py
web_edit_tool
async
¶
web_edit_tool(tool_id: UUID, name: Annotated[str, Form()], description: Annotated[str, Form()], quantity: Annotated[int, Form()]) -> RedirectResponse
Edit an existing tool.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tool_id
|
UUID
|
The UUID of the tool to edit. |
required |
name
|
Annotated[str, Form()]
|
The new name of the tool. |
required |
description
|
Annotated[str, Form()]
|
The new description of the tool. |
required |
quantity
|
Annotated[int, Form()]
|
The new quantity of the tool. |
required |
Returns:
| Type | Description |
|---|---|
RedirectResponse
|
A redirect response to the home page. |
Source code in src/tool_inventory/routers/webapp.py
web_edit_tool_form
async
¶
Render the tool edit form.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
Request
|
The request object. |
required |
tool_id
|
UUID
|
The UUID of the tool to edit. |
required |
Returns:
| Type | Description |
|---|---|
HTMLResponse
|
An HTML response with the tool edit form. |
Source code in src/tool_inventory/routers/webapp.py
web_read_tools
async
¶
Fetch and display all tools.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
Request
|
The request object. |
required |
Returns:
| Type | Description |
|---|---|
HTMLResponse
|
An HTML response with the list of tools. |
Source code in src/tool_inventory/routers/webapp.py
web_search_tools
async
¶
Search for tools.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
Request
|
The request object. |
required |
query
|
str
|
The search query. |
required |
Returns:
| Type | Description |
|---|---|
HTMLResponse
|
An HTML response with the search results. |
Source code in src/tool_inventory/routers/webapp.py
web_update_quantity
async
¶
web_update_quantity(request: Request, tool_id: UUID, action: Annotated[str, Form()]) -> HTMLResponse
Update the quantity of a tool.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
Request
|
The request object. |
required |
tool_id
|
UUID
|
The UUID of the tool to update. |
required |
action
|
Annotated[str, Form()]
|
The action to perform (increment or decrement). |
required |
Returns:
| Type | Description |
|---|---|
HTMLResponse
|
A script to update quantity. |