1- from fastapi import APIRouter , HTTPException , UploadFile , File
1+ from fastapi import APIRouter , UploadFile , File
22from fastapi .responses import Response
33from typing import Dict , Any
44import json
77
88router = APIRouter (prefix = "/bots" )
99
10+
1011@router .put ("/{name}/config" )
1112async def set_config (name : str , config : Dict [str , Any ]):
1213 """
1314 Update bot config
1415 """
1516 return await store .update_config (name , config )
1617
18+
1719@router .get ("/{name}/config" )
1820async def get_config (name : str ):
1921 """
2022 Get bot config
2123 """
2224 return await store .get_config (name )
2325
26+
2427@router .get ("/{name}/export" )
2528async def export_bot (name : str ):
2629 """
@@ -29,10 +32,11 @@ async def export_bot(name: str):
2932 data = await store .export_bot (name )
3033 return Response (
3134 content = json .dumps (data ),
32- media_type = ' application/json' ,
33- headers = {' Content-Disposition' : ' attachment;filename=chatbot_data.json' }
35+ media_type = " application/json" ,
36+ headers = {" Content-Disposition" : " attachment;filename=chatbot_data.json" },
3437 )
3538
39+
3640@router .post ("/{name}/import" )
3741async def import_bot (name : str , file : UploadFile = File (...)):
3842 """
@@ -42,4 +46,4 @@ async def import_bot(name: str, file: UploadFile = File(...)):
4246 content = await file .read ()
4347 json_data = json .loads (content )
4448
45- return await store .import_bot (name , json_data )
49+ return await store .import_bot (name , json_data )
0 commit comments