diff --git a/views/style.css b/src/interface/web/assets/config.css similarity index 100% rename from views/style.css rename to src/interface/web/assets/config.css diff --git a/views/scripts/config.js b/src/interface/web/assets/config.js similarity index 96% rename from views/scripts/config.js rename to src/interface/web/assets/config.js index c3f47743..30ab6858 100644 --- a/views/scripts/config.js +++ b/src/interface/web/assets/config.js @@ -10,7 +10,7 @@ var emptyValueDefault = "🖊️"; /** * Fetch the existing config file. */ -fetch("/config") +fetch("/config/data") .then(response => response.json()) .then(data => { rawConfig = data; @@ -26,15 +26,16 @@ fetch("/config") configForm.addEventListener("submit", (event) => { event.preventDefault(); console.log(rawConfig); - const response = fetch("/config", { + fetch("/config/data", { method: "POST", credentials: "same-origin", headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(rawConfig) - }).then(response => response.json()) - .then((data) => console.log(data)); + }) + .then(response => response.json()) + .then(data => console.log(data)); }); }); diff --git a/src/interface/web/config.html b/src/interface/web/config.html new file mode 100644 index 00000000..27de4aa9 --- /dev/null +++ b/src/interface/web/config.html @@ -0,0 +1,14 @@ + + + + + + Khoj - Configure App + + +
+
+ + + + diff --git a/src/interface/web/index.html b/src/interface/web/index.html index 333abc19..542ae63b 100644 --- a/src/interface/web/index.html +++ b/src/interface/web/index.html @@ -85,7 +85,7 @@ function populate_type_dropdown() { // Populate type dropdown field with enabled search types only var possible_search_types = ["org", "markdown", "ledger", "music", "image"]; - fetch("/config") + fetch("/config/data") .then(response => response.json()) .then(data => { document.getElementById("type").innerHTML = diff --git a/src/main.py b/src/main.py index 92da0e9f..b4d3ec46 100644 --- a/src/main.py +++ b/src/main.py @@ -34,22 +34,21 @@ app = FastAPI() web_directory = f'src/interface/web/' app.mount("/static", StaticFiles(directory=web_directory), name="static") -app.mount("/views", StaticFiles(directory="views"), name="views") -templates = Jinja2Templates(directory="views/") +templates = Jinja2Templates(directory=web_directory) @app.get("/", response_class=FileResponse) def index(): return FileResponse(web_directory + "index.html") -@app.get('/ui', response_class=HTMLResponse) +@app.get('/config', response_class=HTMLResponse) def ui(request: Request): return templates.TemplateResponse("config.html", context={'request': request}) -@app.get('/config', response_model=FullConfig) +@app.get('/config/data', response_model=FullConfig) def config_data(): return config -@app.post('/config') +@app.post('/config/data') async def config_data(updated_config: FullConfig): global config config = updated_config diff --git a/views/config.html b/views/config.html deleted file mode 100644 index befa8e24..00000000 --- a/views/config.html +++ /dev/null @@ -1,12 +0,0 @@ - - - Set directories for your config file. - - - -
-
- - - -