add psycopg2 connect

This commit is contained in:
Sorrel Bri 2019-10-25 10:21:34 -07:00
commit c1991f5241
5 changed files with 7 additions and 6 deletions

3
app.py
View file

@ -18,7 +18,7 @@ app.config.from_object(os.getenv('CONFIGURATION_OBJECT'))
# ! Environment Variable
# TODO export ALLOWED_ORIGIN= whatever the react server is
# TODO cors_allowed_origins=os.getenv('ALLOWED_ORIGIN')
socketio = SocketIO(app, cors_allowed_origins=['http://localhost:3000', 'http://localhost:3001'])
socketio = SocketIO(app, cors_allowed_origins=os.getenv('ALLOWED_ORIGIN'))
def create_app():
CORS(app, resources={
@ -28,3 +28,4 @@ def create_app():
db.init_app(app)
ma.init_app(app)
return app

View file

@ -29,6 +29,6 @@ class TestingConfig(BaseConfig):
class ProductionConfig(BaseConfig):
"""Production configuration."""
SECRET_KEY = ''
SECRET_KEY = os.getenv('SECRET_KEY')
DEBUG = False
SQLALCHEMY_DATABASE_URI = 'postgresql:///'
SQLALCHEMY_DATABASE_URI = 'postgres://mzwaocmnwvesac:d86d256a9e73639d0ac1eba3651f3f5268540e6417b110265fd58398358d1c1b@ec2-174-129-227-51.compute-1.amazonaws.com:5432/d1jbr1uiojpma'

View file

@ -22,7 +22,7 @@ from models.Move import Move
from models.User import User
app.config['SQLALCHEMY_DATABASE_URI'] = 'postgresql://localhost/browser-go'
app.config['SQLALCHEMY_DATABASE_URI'] = os.getenv('DATABASE_URL')
@manager.command
def test():
"""Runs the unit tests without test coverage."""

View file

@ -84,6 +84,6 @@ class GameSchema(ma.Schema):
player_black = fields.Int()
player_white = fields.Int()
game_schema = GameSchema()
games_schema = GameSchema(many=True)

View file

@ -26,7 +26,7 @@ app.register_blueprint(server)
migrate = Migrate(app, db)
# added 10/14
DATABASE_URL = os.environ['DATABASE_URL']
# conn = psycopg2.connect(DATABASE_URL, sslmode='require')
conn = psycopg2.connect(DATABASE_URL, sslmode='require')
if __name__ == '__main__':
socketio.run(app, debug=False)