Get redis connection optionally from the environment
This commit is contained in:
parent
b2d5eac5bf
commit
5e0f733b23
17
app/main.py
17
app/main.py
|
@ -1,6 +1,7 @@
|
|||
import redis
|
||||
import json
|
||||
import uuid
|
||||
import os
|
||||
import random
|
||||
import hashids
|
||||
import asyncio
|
||||
|
@ -14,16 +15,18 @@ from .models import *
|
|||
from starlette.websockets import WebSocket
|
||||
from starlette.middleware.cors import CORSMiddleware
|
||||
|
||||
hashes = hashids.Hashids("a very good salt yes this is nice ok",
|
||||
4, "ABCDEFGHJKLMNPQRSTUVXYZ23456789")
|
||||
hashes = hashids.Hashids("a very good salt yes this is nice ok", 4, "ABCDEFGHJKLMNPQRSTUVXYZ23456789")
|
||||
|
||||
app = FastAPI(title="Cards against idiots")
|
||||
r = redis.Redis(host='redis', port=6379, password='yeet')
|
||||
app.add_middleware(CORSMiddleware, allow_origins=[
|
||||
'*'], allow_methods=["*"], allow_headers=["*"])
|
||||
|
||||
# loop = asyncio.get_event_loop()
|
||||
# r = aioredis.create_redis("redis://redis", loop=loop)
|
||||
r = redis.Redis(
|
||||
host=os.getenv("REDIS_HOST", "redis"),
|
||||
port=os.getenv("REDIS_PORT", 6379),
|
||||
password=os.getenv("REDIS_PASS", "yeet")
|
||||
)
|
||||
|
||||
app.add_middleware(CORSMiddleware, allow_origins=['*'], allow_methods=["*"], allow_headers=["*"])
|
||||
|
||||
cards = {}
|
||||
|
||||
with open("cards.json", encoding="UTF-8") as file:
|
||||
|
|
Loading…
Reference in a new issue