modifeid redis and app
This commit is contained in:
10
app/main.py
10
app/main.py
@@ -16,15 +16,15 @@ app = FastAPI()
|
|||||||
# Secret API Key
|
# Secret API Key
|
||||||
SECRET_PHRASE = os.getenv("API_SECRET", "my_secret_key")
|
SECRET_PHRASE = os.getenv("API_SECRET", "my_secret_key")
|
||||||
|
|
||||||
# Use the Redis password from the environment variable
|
|
||||||
REDIS_URL = os.getenv("REDIS_URL", "redis://:my_redis_password@redis:6379")
|
|
||||||
redis_client = redis.from_url(REDIS_URL)
|
|
||||||
|
|
||||||
|
# Use the Redis password from the environment variable
|
||||||
|
REDIS_URL = os.getenv("REDIS_URL", "redis://redis:6379/0")
|
||||||
|
|
||||||
@app.on_event("startup")
|
@app.on_event("startup")
|
||||||
async def startup():
|
async def startup():
|
||||||
"""Initialize FastAPI Limiter."""
|
"""Initialize FastAPI Limiter with async Redis connection."""
|
||||||
await FastAPILimiter.init(redis_client)
|
redis = await aioredis.from_url(REDIS_URL, decode_responses=True)
|
||||||
|
await FastAPILimiter.init(redis)
|
||||||
|
|
||||||
# Setup Static Files for Documentation
|
# Setup Static Files for Documentation
|
||||||
app.mount("/", StaticFiles(directory="app/docs", html=True), name="docs")
|
app.mount("/", StaticFiles(directory="app/docs", html=True), name="docs")
|
||||||
|
|||||||
@@ -5,10 +5,10 @@ services:
|
|||||||
build: .
|
build: .
|
||||||
container_name: screenshot-api
|
container_name: screenshot-api
|
||||||
ports:
|
ports:
|
||||||
- "80:80"
|
- "8990:80"
|
||||||
environment:
|
environment:
|
||||||
- API_SECRET=kokeserver
|
- API_SECRET=my_secret_key
|
||||||
- REDIS_URL=redis://:my_redis_password@redis:6379
|
- REDIS_URL=redis://redis:6379/0
|
||||||
depends_on:
|
depends_on:
|
||||||
- redis
|
- redis
|
||||||
networks:
|
networks:
|
||||||
@@ -20,7 +20,6 @@ services:
|
|||||||
restart: always
|
restart: always
|
||||||
ports:
|
ports:
|
||||||
- "6379:6379"
|
- "6379:6379"
|
||||||
command: redis-server --requirepass my_redis_password
|
|
||||||
networks:
|
networks:
|
||||||
- screenshot-network
|
- screenshot-network
|
||||||
|
|
||||||
|
|||||||
@@ -2,4 +2,4 @@ fastapi
|
|||||||
uvicorn
|
uvicorn
|
||||||
playwright
|
playwright
|
||||||
fastapi-limiter
|
fastapi-limiter
|
||||||
redis
|
aioredis
|
||||||
|
|||||||
Reference in New Issue
Block a user