from flask import Flask
from flask_talisman import Talisman
from flask_seasurf import SeaSurf
from redditflair.redditflair import redditflair, limiter
from redissession import RedisSessionInterface
from database import db, User, Specials
import os.path

content_security_policy = {
	'script-src': '\'unsafe-inline\'',
	'style-src': '\'self\''
}

def setupApp():
	app = Flask(__name__)
	# HTTP security headers
	Talisman(app, content_security_policy=content_security_policy)
	# CSRF library
	SeaSurf(app)
	# Limiter
	limiter.init_app(app)
	# SQLAlchemy
	app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///cowserver.db'
	db.init_app(app)
	# Blueprints
	app.register_blueprint(redditflair)
	# Redis Session Interface
	app.session_interface = RedisSessionInterface()
	return app
	
def setupDatabase():
	if not os.path.isfile('cowserver.db'):
		with app.app_context():
			db.create_all()


app = setupApp()
setupDatabase()

if __name__ == "__main__":
	app.run(host='0.0.0.0')

from flask import Flask
from flask_talisman import Talisman
from flask_seasurf import SeaSurf
from redditflair.redditflair import redditflair, limiter
from redissession import RedisSessionInterface
from database import db, User, Specials
import os.path

content_security_policy = {
	'script-src': '\'unsafe-inline\'',
	'style-src': '\'self\''
}

def setupApp():
	app = Flask(__name__)

	# HTTP security headers
	Talisman(app, content_security_policy=content_security_policy)

	# CSRF library
	SeaSurf(app)

	# Limiter
	limiter.init_app(app)

	# SQLAlchemy
	app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///cowserver.db'
	app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False

	db.init_app(app)

	# Blueprints
	app.register_blueprint(redditflair)

	# Redis Session Interface
	app.session_interface = RedisSessionInterface()
	
	return app
	
def setupDatabase():
	if not os.path.isfile('cowserver.db'):
		with app.app_context():
			db.create_all()


app = setupApp()
setupDatabase()

if __name__ == "__main__":
	app.run(host='0.0.0.0')

Disable SQLALCHEMY_TRACK_MODIFICATIONS to fix deprecation warning and meet recommendation
Disable SQLALCHEMY_TRACK_MODIFICATIONS to fix deprecation warning and meet recommendation

  from flask import Flask
  from flask_talisman import Talisman
  from flask_seasurf import SeaSurf
  from redditflair.redditflair import redditflair, limiter
  from redissession import RedisSessionInterface
  from database import db, User, Specials
  import os.path
  
  content_security_policy = {
  	'script-src': '\'unsafe-inline\'',
  	'style-src': '\'self\''
  }
  
  def setupApp():
  	app = Flask(__name__)
+ 
  	# HTTP security headers
  	Talisman(app, content_security_policy=content_security_policy)
+ 
  	# CSRF library
  	SeaSurf(app)
+ 
  	# Limiter
  	limiter.init_app(app)
+ 
  	# SQLAlchemy
  	app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///cowserver.db'
+ 	app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
+ 
  	db.init_app(app)
+ 
  	# Blueprints
  	app.register_blueprint(redditflair)
+ 
  	# Redis Session Interface
  	app.session_interface = RedisSessionInterface()
+ 	
  	return app
  	
  def setupDatabase():
  	if not os.path.isfile('cowserver.db'):
  		with app.app_context():
  			db.create_all()
  
  
  app = setupApp()
  setupDatabase()
  
  if __name__ == "__main__":
  	app.run(host='0.0.0.0')
  
Disable SQLALCHEMY_TRACK_MODIFICATIONS to fix deprecation warning and meet recommendation
## Code Before:
from flask import Flask
from flask_talisman import Talisman
from flask_seasurf import SeaSurf
from redditflair.redditflair import redditflair, limiter
from redissession import RedisSessionInterface
from database import db, User, Specials
import os.path

content_security_policy = {
	'script-src': '\'unsafe-inline\'',
	'style-src': '\'self\''
}

def setupApp():
	app = Flask(__name__)
	# HTTP security headers
	Talisman(app, content_security_policy=content_security_policy)
	# CSRF library
	SeaSurf(app)
	# Limiter
	limiter.init_app(app)
	# SQLAlchemy
	app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///cowserver.db'
	db.init_app(app)
	# Blueprints
	app.register_blueprint(redditflair)
	# Redis Session Interface
	app.session_interface = RedisSessionInterface()
	return app
	
def setupDatabase():
	if not os.path.isfile('cowserver.db'):
		with app.app_context():
			db.create_all()


app = setupApp()
setupDatabase()

if __name__ == "__main__":
	app.run(host='0.0.0.0')

## Instruction:
Disable SQLALCHEMY_TRACK_MODIFICATIONS to fix deprecation warning and meet recommendation
## Code After:
from flask import Flask
from flask_talisman import Talisman
from flask_seasurf import SeaSurf
from redditflair.redditflair import redditflair, limiter
from redissession import RedisSessionInterface
from database import db, User, Specials
import os.path

content_security_policy = {
	'script-src': '\'unsafe-inline\'',
	'style-src': '\'self\''
}

def setupApp():
	app = Flask(__name__)

	# HTTP security headers
	Talisman(app, content_security_policy=content_security_policy)

	# CSRF library
	SeaSurf(app)

	# Limiter
	limiter.init_app(app)

	# SQLAlchemy
	app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///cowserver.db'
	app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False

	db.init_app(app)

	# Blueprints
	app.register_blueprint(redditflair)

	# Redis Session Interface
	app.session_interface = RedisSessionInterface()
	
	return app
	
def setupDatabase():
	if not os.path.isfile('cowserver.db'):
		with app.app_context():
			db.create_all()


app = setupApp()
setupDatabase()

if __name__ == "__main__":
	app.run(host='0.0.0.0')
