Added Application HolidayViewer

This commit is contained in:
Kodjo Sossouvi
2025-06-27 07:26:58 +02:00
parent 66ea45f501
commit 9f4b8ab4d0
87 changed files with 3756 additions and 212 deletions

View File

@@ -1,7 +1,7 @@
# global layout
import asyncio
import logging.config
import requests
import yaml
from fasthtml.common import *
@@ -18,6 +18,7 @@ from components.page_layout_new import page_layout_new, page_layout_lite
from components.register.components.Register import Register
from components.register.constants import ROUTE_ROOT as REGISTER_ROUTE_ROOT
from components.register.constants import Routes as RegisterRoutes
from config import APP_PORT
from constants import Routes
from core.dbengine import DbException
from core.instance_manager import InstanceManager
@@ -45,9 +46,13 @@ logger = logging.getLogger("MainApp")
links = [
# start with daisyui
Link(href="https://cdn.jsdelivr.net/npm/daisyui@5", rel="stylesheet", type="text/css"),
Link(href="https://cdn.jsdelivr.net/npm/daisyui@5/themes.css", rel="stylesheet", type="text/css"),
Script(src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"),
# Link(href="https://cdn.jsdelivr.net/npm/daisyui@5", rel="stylesheet", type="text/css"),
# Link(href="https://cdn.jsdelivr.net/npm/daisyui@5/themes.css", rel="stylesheet", type="text/css"),
# Script(src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"),
Link(href="./assets/daisyui-5.css", rel="stylesheet", type="text/css"),
Link(href="./assets/daisyui-5-themes.css", rel="stylesheet", type="text/css"),
Script(src="./assets/tailwindcss-browser@4.js"),
# Old drawer layout
Script(src="./assets/DrawerLayout.js", defer=True),
@@ -131,21 +136,9 @@ def register_component(name, path, app_module_name):
links.extend(component_links)
except ImportError:
logging.error(f"Could not import module {path}")
def query_mistral(prompt):
"""Send a query to the Mistral model via Ollama API"""
ollama_host = os.environ.get('OLLAMA_HOST', 'http://localhost:11434')
response = requests.post(
f"{ollama_host}/api/generate",
json={
"model": "mistral",
"prompt": prompt,
"stream": False
}
)
return response.json()
logger.error(f"Could not import module {path}. Failed to register component {name}.")
except AttributeError as ex:
logger.error(f"Error: {ex}. Failed to register component {name}.")
register_component("login", "components.login", "LoginApp")
@@ -153,11 +146,14 @@ register_component("register", "components.register", "RegisterApp")
register_component("theme_controller", "components.themecontroller", "ThemeControllerApp")
register_component("main_layout", "components.drawerlayout", "DrawerLayoutApp")
register_component("tabs", "components.tabs", "TabsApp") # before repositories
register_component("applications", "components.applications", "ApplicationsApp")
register_component("repositories", "components.repositories", "RepositoriesApp")
register_component("add_stuff", "components.addstuff", None)
register_component("form", "components.form", "FormApp")
register_component("datagrid_new", "components.datagrid_new", "DataGridApp")
register_component("debugger", "components.debugger", "DebuggerApp")
register_component("ai_buddy", "components.aibuddy", "AIBuddyApp")
register_component("admin", "components.admin", "AdminApp")
routes.extend([
# old stuffs
@@ -288,19 +284,17 @@ def get(session):
return Titled("I like toast")
async def main():
logger.info(f" Starting FastHTML server on http://localhost:{APP_PORT}")
serve(port=APP_PORT)
if __name__ == "__main__":
# Start your application
print("Application starting...")
print("Checking if Mistral model is available...")
try:
requests.post(
f"{os.environ.get('OLLAMA_HOST', 'http://localhost:11434')}/api/pull",
json={"name": "mistral"}
)
print("Mistral model is ready")
except Exception as e:
print(f"Error pulling Mistral model: {e}")
serve(port=5001)
# Start your application
logger.info("Application starting...")
try:
asyncio.run(main())
except KeyboardInterrupt:
logger.info("\nStopping application...")
except Exception as e:
logger.error(f"Error: {e}")