I can use commands
This commit is contained in:
@@ -5,8 +5,9 @@ from typing import Optional
|
||||
from fasthtml.fastapp import fast_app
|
||||
|
||||
from myfasthtml.core.constants import Routes, ROUTE_ROOT
|
||||
from myfasthtml.core.utils import mount_if_not_exists
|
||||
|
||||
commands_app, rt = fast_app()
|
||||
commands_app, commands_rt = fast_app()
|
||||
logger = logging.getLogger("Commands")
|
||||
|
||||
|
||||
@@ -93,7 +94,7 @@ class CommandsManager:
|
||||
return CommandsManager.commands.clear()
|
||||
|
||||
|
||||
@rt(Routes.Commands)
|
||||
@commands_rt(Routes.Commands)
|
||||
def post(session: str, c_id: str):
|
||||
"""
|
||||
Default routes for all commands.
|
||||
@@ -106,4 +107,16 @@ def post(session: str, c_id: str):
|
||||
if command:
|
||||
return command.execute()
|
||||
|
||||
return None
|
||||
raise ValueError(f"Command with ID '{c_id}' not found.")
|
||||
|
||||
|
||||
def mount_commands(app):
|
||||
"""
|
||||
Mounts the commands_app to the given application instance if the route does not already exist.
|
||||
|
||||
:param app: The application instance to which the commands_app will be mounted.
|
||||
:type app: Any
|
||||
:return: Returns the result of the mount operation performed by mount_if_not_exists.
|
||||
:rtype: Any
|
||||
"""
|
||||
return mount_if_not_exists(app, ROUTE_ROOT, commands_app)
|
||||
|
||||
Reference in New Issue
Block a user