From cc8c9d52934b5b34fbe4594fdd095c7fc3604a23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9cile=20Vuilleumier?= Date: Wed, 10 Apr 2024 13:21:17 +0200 Subject: [PATCH] Upgrade Python and FastAPI --- Dockerfile | 2 +- Makefile | 4 ++-- README.md | 4 ++-- tests/integration_test.sh | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index 5a2aab6..066fa5c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM tiangolo/uvicorn-gunicorn-fastapi:python3.7-2020-12-19 +FROM tiangolo/uvicorn-gunicorn-fastapi:python3.11 COPY ./bridge-style /tmp/bridge-style COPY requirements.txt /tmp/ diff --git a/Makefile b/Makefile index f5eefad..d384a5e 100644 --- a/Makefile +++ b/Makefile @@ -36,12 +36,12 @@ serve: init-geoserver convert: ## Convert a style from lyrx to sld (input files set in config.mk) and upload it to GeoServer convert: serve psql -h $(PG_HOST) -p $(PG_PORT) -U $(PG_USER) -d $(PG_DATABASE) -a -f $(BASE_PATH)/$(SQL_SCRIPT) - curl --location -d @$(BASE_PATH)/$(LYRX_FILE) $(LYRX2SLD_URL) -o $(BASE_PATH)/output.zip + curl -H 'Content-Type: application/json' --location -d @$(BASE_PATH)/$(LYRX_FILE) $(LYRX2SLD_URL) -o $(BASE_PATH)/output.zip curl -u admin:geoserver -XPOST -H "Content-type: application/zip" --data-binary @$(BASE_PATH)/output.zip $(GEOSERVER_URL)rest/styles .PHONY: update update: ## Convert again the lyrx and update the already existing "Default Styler" style. - curl --location -d @$(BASE_PATH)/$(LYRX_FILE) $(LYRX2SLD_URL) -o $(BASE_PATH)/output.zip + curl -H 'Content-Type: application/json'--location -d @$(BASE_PATH)/$(LYRX_FILE) $(LYRX2SLD_URL) -o $(BASE_PATH)/output.zip curl -u admin:geoserver -XPUT -H "Content-type: application/zip" --data-binary @$(BASE_PATH)/output.zip $(GEOSERVER_URL)rest/styles/Default%20Styler .PHONY: stop diff --git a/README.md b/README.md index 7213be5..0ca14c2 100644 --- a/README.md +++ b/README.md @@ -24,12 +24,12 @@ docker run --rm -d --name lyrx2sld -p 80:80 camptocamp/lyrx2sld:latest ### Usage lyrx data should be sent as a file to http://localhost/v1/lyrx2sld/ through a POST request. The converted SLD styling is sent back in the response content (content type: application/x-zip-compressed). Example using `curl`: ``` -curl --location -d @/path/to/input.lyrx http://localhost/v1/lyrx2sld/ -o /path/to/output.zip +curl --location -d @/path/to/input.lyrx -H 'Content-Type: application/json' -o /path/to/output.zip "http://localhost/v1/lyrx2sld/" ``` Optional request parameter: `replaceesri` to replace ESRI font markers with standard symbols, to be set to `true` or `false` (default): ``` -curl --location -d @/path/to/input.lyrx "http://localhost/v1/lyrx2sld/?replaceesri=true" -o /path/to/output.zip +curl --location -d @/path/to/input.lyrx -H 'Content-Type: application/json' -o /path/to/output.zip "http://localhost/v1/lyrx2sld/?replaceesri=true" ``` Warnings and errors from bridge-style are written to the logs - to view them: ``` diff --git a/tests/integration_test.sh b/tests/integration_test.sh index 4360997..1d871fa 100755 --- a/tests/integration_test.sh +++ b/tests/integration_test.sh @@ -4,7 +4,7 @@ SERVICE="http://localhost/v1/lyrx2sld/" INPUT_FILE="tests/data/withicons.lyrx" OUTPUT_FILE="/tmp/output.zip" -STATUS_CODE=$(curl --write-out %{http_code} -v -d @$INPUT_FILE -o $OUTPUT_FILE $SERVICE) +STATUS_CODE=$(curl --write-out %{http_code} -v -d @$INPUT_FILE -H 'Content-Type: application/json' -o $OUTPUT_FILE $SERVICE) if [ -f "$OUTPUT_FILE" ] && [ $STATUS_CODE = 200 ]; then echo "Output file has been created and request status code is 200"