From 3db06eee3f0f1b3e118c23635ead597a197bc6b6 Mon Sep 17 00:00:00 2001 From: Saba Date: Sat, 27 Nov 2021 10:49:33 -0500 Subject: [PATCH] Basic example of serving conifg as JSON and retriving on button click --- src/main.py | 12 +++++++++++- views/config.html | 48 +++++------------------------------------------ 2 files changed, 16 insertions(+), 44 deletions(-) diff --git a/src/main.py b/src/main.py index d82d242e..d8c4c30c 100644 --- a/src/main.py +++ b/src/main.py @@ -7,6 +7,7 @@ from typing import Optional import uvicorn from fastapi import FastAPI, Request from fastapi.responses import HTMLResponse +from fastapi.staticfiles import StaticFiles from fastapi.templating import Jinja2Templates # Internal Packages @@ -20,15 +21,21 @@ from src.processor.conversation.gpt import converse, message_to_prompt model = SearchModels() search_config = SearchConfig() processor_config = ProcessorConfig() +config = {} app = FastAPI() -# app.mount("/views", StaticFiles(directory="./views"), name="views") +app.mount("/views", StaticFiles(directory="views"), name="views") templates = Jinja2Templates(directory="views/") @app.get('/ui', response_class=HTMLResponse) def ui(request: Request): return templates.TemplateResponse("config.html", context={'request': request}) +@app.get('/config') +def config(): + print(config) + return config + @app.get('/search') def search(q: str, n: Optional[int] = 5, t: Optional[SearchType] = None): if q is None or q == '': @@ -173,6 +180,9 @@ if __name__ == '__main__': # Load config from CLI args = cli(sys.argv[1:]) + # Store the path to the config file. + config = args.config + # Initialize Search from Config model, search_config = initialize_search(args.config, args.regenerate, args.verbose) diff --git a/views/config.html b/views/config.html index d4615945..cec508d8 100644 --- a/views/config.html +++ b/views/config.html @@ -3,49 +3,11 @@ Set directories for your config file. -
- -

Org notes

- - - - + + +

+

content-type

- - - + \ No newline at end of file