Skip to content

Commit

Permalink
replace the JSON credentials with .env / dotenv
Browse files Browse the repository at this point in the history
  • Loading branch information
metazool committed Aug 20, 2024
1 parent 7abf7a1 commit c81c9e7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
16 changes: 8 additions & 8 deletions src/os_api/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
"""

import asyncio
import json
import logging
from pathlib import Path
import os
from time import perf_counter

import aioboto3
import boto3
import uvicorn
from botocore.exceptions import NoCredentialsError, PartialCredentialsError
from dotenv import load_dotenv
from fastapi import FastAPI, File, Form, Query, UploadFile
from fastapi.middleware.cors import CORSMiddleware
from fastapi.responses import JSONResponse, RedirectResponse
Expand Down Expand Up @@ -51,13 +51,13 @@
)


# Load AWS credentials and S3 bucket name from config file
with Path(__file__).with_name("credentials.json").open("r", encoding="utf-8") as config_file:
aws_credentials = json.load(config_file)
# Load AWS credentials and S3 bucket name from .env file
# Rather than depend on the presence of credentials.json in the package
load_dotenv()

AWS_ACCESS_KEY_ID = aws_credentials["AWS_ACCESS_KEY_ID"]
AWS_SECRET_ACCESS_KEY = aws_credentials["AWS_SECRET_ACCESS_KEY"]
AWS_URL_ENDPOINT = aws_credentials["AWS_URL_ENDPOINT"]
AWS_ACCESS_KEY_ID = os.environ.get("AWS_ACCESS_KEY_ID", "")
AWS_SECRET_ACCESS_KEY = os.environ.get("AWS_SECRET_ACCESS_KEY", "")
AWS_URL_ENDPOINT = os.environ.get("AWS_URL_ENDPOINT", "")

CONCURRENCY_LIMIT = 200 # Adjust this value based on your server capabilities

Expand Down
5 changes: 0 additions & 5 deletions src/os_api/credentials.json

This file was deleted.

0 comments on commit c81c9e7

Please sign in to comment.