create tables

This commit is contained in:
Łukasz Jędyk 2022-01-24 21:41:18 +01:00
parent 5ba33a5f0f
commit 9bc20aea07

View File

@ -11,13 +11,19 @@ def create_app():
app = Flask('ayct-backend') app = Flask('ayct-backend')
app.config['SECRET_KEY'] = os.getenv('SECRET_KEY') app.config['SECRET_KEY'] = os.getenv('SECRET_KEY')
app.config['SQLALCHEMY_DATABASE_URI'] = os.getenv('DATABASE_URL') database_uri = os.getenv('DATABASE_URL')
if database_uri and database_uri.startswith("postgres://"):
database_uri = database_uri.replace("postgres://", "postgresql://", 1)
app.config['SQLALCHEMY_DATABASE_URI'] = database_uri
app.config['TWITTER_CONSUMER_KEY'] = os.getenv('TWITTER_CONSUMER_KEY') app.config['TWITTER_CONSUMER_KEY'] = os.getenv('TWITTER_CONSUMER_KEY')
app.config['TWITTER_CONSUMER_SECERT'] = os.getenv('TWITTER_CONSUMER_SECERT') app.config['TWITTER_CONSUMER_SECERT'] = os.getenv('TWITTER_CONSUMER_SECERT')
twitter_db.init_app(app) twitter_db.init_app(app)
campaign_db.init_app(app) campaign_db.init_app(app)
twitter_db.create_all()
#campaign_db.create_all()
app.register_blueprint(twitter, url_prefix='/twitter') app.register_blueprint(twitter, url_prefix='/twitter')
app.register_blueprint(campaign, url_prefix='/campaign') app.register_blueprint(campaign, url_prefix='/campaign')