From 829c0bc18b5ad068dee20bc593419fb581d0740d Mon Sep 17 00:00:00 2001 From: Vincentqyw Date: Sun, 6 Oct 2024 00:10:42 +0800 Subject: [PATCH] add: netlify.toml --- Dockerfile | 1 - api/client.py | 14 ++++++++++---- netlify.toml | 11 +++++++++++ 3 files changed, 21 insertions(+), 5 deletions(-) create mode 100644 netlify.toml diff --git a/Dockerfile b/Dockerfile index b0c5f59..09fd374 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,7 +11,6 @@ RUN apt-get update && apt-get install -y git-lfs RUN git lfs install # Clone the Git repository -# RUN git clone https://huggingface.co/spaces/Realcat/image-matching-webui /code RUN git clone --recursive https://github.com/Vincentqyw/image-matching-webui.git /code RUN conda create -n imw python=${PYTHON_VERSION} diff --git a/api/client.py b/api/client.py index 2d1313b..c357642 100644 --- a/api/client.py +++ b/api/client.py @@ -1,15 +1,21 @@ +import os import argparse import pickle import time from typing import Dict - import numpy as np import requests from loguru import logger -API_URL_MATCH = "http://127.0.0.1:8001/v1/match" -API_URL_EXTRACT = "http://127.0.0.1:8001/v1/extract" -API_URL_EXTRACT_V2 = "http://127.0.0.1:8001/v2/extract" +URL = "http://127.0.0.1:8001" +if "REMOTE_URL_RAILWAY" in os.environ: + URL = os.environ["REMOTE_URL_RAILWAY"] + +logger.info(f"API URL: {URL}") + +API_URL_MATCH = f"{URL}/v1/match" +API_URL_EXTRACT = f"{URL}/v1/extract" +API_URL_EXTRACT_V2 = f"{URL}/v2/extract" def send_generate_request(path0: str, path1: str) -> Dict[str, np.ndarray]: diff --git a/netlify.toml b/netlify.toml new file mode 100644 index 0000000..d665d74 --- /dev/null +++ b/netlify.toml @@ -0,0 +1,11 @@ +[build] + command = "pip install -r requirements.txt && python server.py" + publish = "." + +[context.production.environment] + PYTHON_VERSION = "3.10.10" + +[[redirects]] + from = "/*" + to = "/index.html" + status = 200