-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.py
More file actions
35 lines (25 loc) · 953 Bytes
/
config.py
File metadata and controls
35 lines (25 loc) · 953 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
"""
All these secret keys need to be set on Docker container run,
as environment variables, don't forget this or application wont run!
or in the Docker compose file, multiple ways to do this!
'some-redis' is the docker container name
'postgre-sql' is the docker container name
"""
import redis
from redis import Redis, RedisError
import os
from flask import Flask
# PostgreSQL database
import psycopg2
from psycopg2.extras import RealDictCursor
# Keys
SECRET_KEY = os.getenv('FLASK_SECRET_KEY')
if SECRET_KEY is None:
raise ValueError(
"No secret key set. Please set the FLASK_SECRET_KEY environment variable.")
POSTGRESQL_PASSWORD = os.getenv('POSTGRESQL_PASSWORD')
JWT_KEY = os.getenv('JWT_KEY')
# Addresses
redis_address = 'redis://some-redis:6379/0'
postgresql_address = f'postgresql://conrad:{POSTGRESQL_PASSWORD}@postgre-sql:5432/mydatabase'
redis_client = redis.Redis(host='some-redis', port=6379, db=0)