mirror of
https://github.com/khoj-ai/khoj.git
synced 2024-11-23 23:48:56 +01:00
Write back to the raw config.yml file on update
This commit is contained in:
parent
8837b02de6
commit
19b81e82f0
1 changed files with 6 additions and 2 deletions
|
@ -22,6 +22,7 @@ model = SearchModels()
|
||||||
search_config = SearchConfig()
|
search_config = SearchConfig()
|
||||||
processor_config = ProcessorConfig()
|
processor_config = ProcessorConfig()
|
||||||
config = {}
|
config = {}
|
||||||
|
config_file = ""
|
||||||
app = FastAPI()
|
app = FastAPI()
|
||||||
|
|
||||||
app.mount("/views", StaticFiles(directory="views"), name="views")
|
app.mount("/views", StaticFiles(directory="views"), name="views")
|
||||||
|
@ -37,7 +38,7 @@ def config():
|
||||||
|
|
||||||
@app.post('/config')
|
@app.post('/config')
|
||||||
async def config(updated_config: FullConfig):
|
async def config(updated_config: FullConfig):
|
||||||
with open('config.yml', 'w') as outfile:
|
with open(config_file, 'w') as outfile:
|
||||||
yaml.dump(yaml.safe_load(updated_config.json()), outfile)
|
yaml.dump(yaml.safe_load(updated_config.json()), outfile)
|
||||||
outfile.close()
|
outfile.close()
|
||||||
return updated_config
|
return updated_config
|
||||||
|
@ -185,8 +186,11 @@ def shutdown_event():
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
# Load config from CLI
|
# Load config from CLI
|
||||||
args = cli(sys.argv[1:])
|
args = cli(sys.argv[1:])
|
||||||
|
|
||||||
|
# Stores the file path to the config file.
|
||||||
|
config_file = args.config_file
|
||||||
|
|
||||||
# Store the path to the config file.
|
# Store the raw config data.
|
||||||
config = args.config
|
config = args.config
|
||||||
|
|
||||||
# Initialize Search from Config
|
# Initialize Search from Config
|
||||||
|
|
Loading…
Reference in a new issue