You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
774 B
35 lines
774 B
import os
|
|
from pathlib import Path
|
|
|
|
from fastapi import Depends, FastAPI, UploadFile
|
|
|
|
from .geojson2vt import geojson2vt
|
|
|
|
#prepare data storage
|
|
def set_storage():
|
|
storage_path = os.environ.get("STATE_DIRECTORY")
|
|
if storage_path:
|
|
try:
|
|
os.mkdir(Path(storage_path, "geojsons"))
|
|
except FileExistsError:
|
|
pass
|
|
try:
|
|
os.mkdir(Path(storage_path, "vector_tiles"))
|
|
except FileExistsError:
|
|
pass
|
|
return storage_path
|
|
|
|
STORAGE_PATH = set_storage()
|
|
|
|
app = FastAPI()
|
|
|
|
|
|
@app.get("/")
|
|
async def root():
|
|
return {"message": "Hello World!"}
|
|
|
|
@app.post("/upload/")
|
|
async def create_upload_file(file: UploadFile):
|
|
geojson2vt(file, storage_path=STORAGE_PATH)
|
|
return {"filename": file.filename}
|