From a73f132b4cac0ae2db99f856f17c24d12a065d8f Mon Sep 17 00:00:00 2001 From: FredTheNoob Date: Fri, 1 Dec 2023 11:46:34 +0100 Subject: [PATCH] add env stuff and post to C --- main.py | 16 ++++++++++++---- requirements.txt | 3 ++- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/main.py b/main.py index 16ae074..238a2b6 100644 --- a/main.py +++ b/main.py @@ -1,4 +1,3 @@ -from socket import timeout from components import * from components.EntityLinker import entitylinkerFunc import json, os, time, string @@ -10,17 +9,26 @@ from fastapi import FastAPI, HTTPException, Request, Query from fastapi.staticfiles import StaticFiles from fastapi.templating import Jinja2Templates - +import requests +from dotenv import load_dotenv templates = Jinja2Templates(directory="public") app = FastAPI(title="API") -DIRECTORY_TO_WATCH = "data_from_A/" +load_dotenv() +DIRECTORY_TO_WATCH = str(os.getenv("DIRECTORY_TO_WATCH")) +PIPELINE_C_URL = str(os.getenv("PIPELINE_C_URL")) +PIPELINE_C_AUTHORIZATION = str(os.getenv("PIPELINE_C_AUTHORIZATION")) +ACCESS_API_AUTHORIZATION = str(os.getenv("ACCESS_API_AUTHORIZATION")) async def newFileCreated(file_path: str): time.sleep(1) await modifyTxt(file_path) - await processInput(file_path) + outputJSON = await processInput(file_path) + + Headers = { "Authorization" : PIPELINE_C_AUTHORIZATION, "Access-Authorization": ACCESS_API_AUTHORIZATION } + status = requests.post(PIPELINE_C_URL, json=outputJSON, headers=Headers) + print(status.text) dirWatcher = dirWatcher = DirectoryWatcher( diff --git a/requirements.txt b/requirements.txt index 4c86b56..fe9d2f2 100644 --- a/requirements.txt +++ b/requirements.txt @@ -11,4 +11,5 @@ pytest-cov==3.0.0 langdetect==1.0.9 httpx fuzzywuzzy -watchdog \ No newline at end of file +watchdog +python-dotenv \ No newline at end of file