pbr-ayct-backend/ayct_backend/__init__.py

29 lines
952 B
Python
Raw Permalink Normal View History

2022-01-24 19:37:27 +01:00
import os
2022-05-10 11:37:54 +02:00
from flask import Flask
2022-01-24 20:26:12 +01:00
from ayct_backend.twitter import twitter
from ayct_backend.campaign import campaign
2022-05-10 11:37:54 +02:00
from ayct_backend.models import db
2022-01-24 20:06:33 +01:00
#import pbrAyctCore.core as core
2021-12-01 14:25:42 +01:00
def create_app():
app = Flask('ayct-backend')
2022-01-24 19:37:27 +01:00
app.config['SECRET_KEY'] = os.getenv('SECRET_KEY')
2022-01-24 21:41:18 +01:00
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
2022-01-24 19:37:27 +01:00
app.config['TWITTER_CONSUMER_KEY'] = os.getenv('TWITTER_CONSUMER_KEY')
app.config['TWITTER_CONSUMER_SECERT'] = os.getenv('TWITTER_CONSUMER_SECERT')
2022-05-10 11:37:54 +02:00
db.init_app(app)
db.create_all(app=app)
2022-01-24 21:41:18 +01:00
2022-01-24 19:37:27 +01:00
app.register_blueprint(twitter, url_prefix='/twitter')
app.register_blueprint(campaign, url_prefix='/campaign')
2021-12-01 14:25:42 +01:00
@app.route('/hello')
def hello():
2022-01-24 20:06:33 +01:00
return "Hello world!"
2021-12-01 14:25:42 +01:00
return app