Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#15 Way around using env variables from google cloud function env #49

Merged
merged 1 commit into from
Mar 22, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 16 additions & 15 deletions config.py
Original file line number Diff line number Diff line change
@@ -1,30 +1,31 @@
"""Flask configuration."""
from os import environ, path
from dotenv import load_dotenv
import os
FLASK_ENV = os.environ.get('FLASK_ENV', 'development')

basedir = path.abspath(path.dirname(__file__))
load_dotenv(path.join(basedir, '.env'))
if FLASK_ENV == 'development':
from os import environ, path
from dotenv import load_dotenv
basedir = path.abspath(path.dirname(__file__))
load_dotenv(path.join(basedir, '.env'))

TESTING = environ.get('TESTING')
DEBUG = environ.get('DEBUG')
FLASK_ENV = environ.get('FLASK_ENV')
TESTING = os.environ.get('TESTING')
DEBUG = os.environ.get('DEBUG')

# Database configuration
POSTGRES = {
'user': environ.get('DB_USER'),
'password': environ.get('DB_PASSWORD'),
'database': environ.get('DB_NAME'),
'host': environ.get('DB_HOST'),
'port': environ.get('DB_PORT'),
'connection_name': environ.get('CONNECTION_NAME'),
'user': os.environ.get('DB_USER'),
'password': os.environ.get('DB_PASSWORD'),
'database': os.environ.get('DB_NAME'),
'host': os.environ.get('DB_HOST'),
'port': os.environ.get('DB_PORT'),
'connection_name': os.environ.get('CONNECTION_NAME'),
}
# For socket based connection
SQLALCHEMY_DATABASE_URI = 'postgresql://%(user)s:%(password)s/%(database)s?host=%(connection_name)s/' % POSTGRES
if FLASK_ENV == 'development':
# For TCP based conneciton
SQLALCHEMY_DATABASE_URI = 'postgresql://%(user)s:%(password)s@%(host)s:%(port)s/%(database)s' % POSTGRES


SQLALCHEMY_TRACK_MODIFICATIONS = True
WTF_CSRF_ENABLED = True
SECRET_KEY = environ.get('SECRET_KEY')
SECRET_KEY = os.environ.get('SECRET_KEY')