Spaces:
Runtime error
Runtime error
sghorbal commited on
Commit ·
5439a54
1
Parent(s): 3b9f745
load api key from .env and send data in request body
Browse files- dags/new_transaction.py +9 -2
- requirements.txt +1 -0
dags/new_transaction.py
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
|
|
| 1 |
import logging
|
| 2 |
import requests
|
| 3 |
from datetime import datetime, timedelta
|
| 4 |
from airflow import DAG
|
| 5 |
from airflow.decorators import task
|
| 6 |
import json
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
default_args = {
|
| 9 |
"owner": "airflow",
|
|
@@ -75,10 +82,10 @@ def _push_transaction(ti):
|
|
| 75 |
|
| 76 |
api_response = requests.post(
|
| 77 |
url='https://slimg-fraud-detection-service-api.hf.space/transaction/process',
|
| 78 |
-
|
| 79 |
headers={
|
| 80 |
'Content-Type': 'application/json',
|
| 81 |
-
'Authorization':
|
| 82 |
},
|
| 83 |
)
|
| 84 |
|
|
|
|
| 1 |
+
import os
|
| 2 |
import logging
|
| 3 |
import requests
|
| 4 |
from datetime import datetime, timedelta
|
| 5 |
from airflow import DAG
|
| 6 |
from airflow.decorators import task
|
| 7 |
import json
|
| 8 |
+
from dotenv import load_dotenv
|
| 9 |
+
|
| 10 |
+
# Load environment variables from .env file
|
| 11 |
+
load_dotenv()
|
| 12 |
+
|
| 13 |
+
FASTAPI_API_KEY = os.getenv("FASTAPI_API_KEY")
|
| 14 |
|
| 15 |
default_args = {
|
| 16 |
"owner": "airflow",
|
|
|
|
| 82 |
|
| 83 |
api_response = requests.post(
|
| 84 |
url='https://slimg-fraud-detection-service-api.hf.space/transaction/process',
|
| 85 |
+
data=json.dumps(data),
|
| 86 |
headers={
|
| 87 |
'Content-Type': 'application/json',
|
| 88 |
+
'Authorization': FASTAPI_API_KEY
|
| 89 |
},
|
| 90 |
)
|
| 91 |
|
requirements.txt
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
|
|
| 1 |
requests
|
| 2 |
sqlalchemy
|
| 3 |
psycopg2-binary
|
|
|
|
| 1 |
+
python-dotenv
|
| 2 |
requests
|
| 3 |
sqlalchemy
|
| 4 |
psycopg2-binary
|