Skip to content
Snippets Groups Projects
Commit c41733d0 authored by Alexis Durgnat's avatar Alexis Durgnat :milky_way:
Browse files

Fix tag filename and api retval

parent 8b635c25
Branches
No related tags found
No related merge requests found
......@@ -12,6 +12,7 @@ TAG_LIST_NAME = "tags.json"
app = FastAPI()
class MapData(BaseModel):
esri: str
arucos: List[Dict]
......@@ -19,14 +20,16 @@ class MapData(BaseModel):
@app.post("/map")
async def post_map(the_map: MapData):
write_map(the_map)
return "ok"
result = write_map(the_map)
return {"success": result}
def write_map(map_data: MapData):
dir_name = os.getenv("ESRI_OUTPUT_DIRECTORY", default=OUTPUT_DIR)
if not os.path.exists(dir_name):
os.makedirs(dir_name, exist_ok=True)
map_filename = path_join(dir_name, MAP_NAME)
tag_filename = path_join(dir_name, MAP_NAME)
tag_filename = path_join(dir_name, TAG_LIST_NAME)
with open(map_filename, 'w') as map_file:
map_file.write(map_data.esri)
with open(tag_filename, 'w') as tag_file:
......@@ -34,6 +37,7 @@ def write_map(map_data: MapData):
"tags": map_data.arucos
}
json.dump(jdic, tag_file)
return True
def path_join(p, f):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment