def generate_context(config): """Create the Flask app context and initializes any extensions such as Celery, Redis, SQLAlchemy, etc. :param dict config: Partial Flask config dict from generate_config(). :return: The Flask app instance. """ flask_app = Flask(__name__) flask_app.config.update(config) flask_app.config['TESTING'] = True flask_app.config['CELERY_ACCEPT_CONTENT'] = ['pickle'] if 'SQLALCHEMY_DATABASE_URI' in flask_app.config: db = SQLAlchemy(flask_app) db.engine.execute('DROP TABLE IF EXISTS celery_tasksetmeta;') elif 'REDIS_URL' in flask_app.config: redis = Redis(flask_app) redis.flushdb() Celery(flask_app) return flask_app
# from flask_restful import Resource, Api from flask_wtf import FlaskForm from wtforms import StringField, SubmitField, validators import json # Configure a secret SECRET_KEY # We will later learn much better ways to do this!! app = Flask(__name__) app.config['SECRET_KEY'] = 'mysecretkey' # app.config['REDIS_HOST'] = '192.168.99.100' # app.config['REDIS_PORT'] = 6379 # app.config['REDIS_DB'] = 0 redis = Redis(app) redis.flushdb() # api = Api(app) # # # class AddNewList(Resource): # # def get(self): # return {'status': 'ok'} # # # api.add_resource(AddNewList, '/add_new_list') # class ShowLists(Resource): # # def get(self):