from flask import Flask
from cyclonejet.views.frontend import frontend
from flaskext.sqlalchemy import SQLAlchemy
import settings


app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = settings.DB_URI
app.register_module(frontend)

db = SQLAlchemy(app)

from flask import Flask, render_template

from cyclonejet.views.frontend import frontend
from cyclonejet.views.errors import errors

from flaskext.sqlalchemy import SQLAlchemy
import settings

app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = settings.DB_URI

#Blueprint registration
app.register_blueprint(frontend)
app.register_blueprint(errors)

#DB intialization
db = SQLAlchemy(app)


#Custom Error handling (move this somewhere else?)
@app.errorhandler(404)
def page_not_found(e):
    return render_template('404.html'), 404



Switch to Blueprints, custom 404 handler.
Switch to Blueprints, custom 404 handler.

- from flask import Flask
+ from flask import Flask, render_template
+ 
  from cyclonejet.views.frontend import frontend
+ from cyclonejet.views.errors import errors
+ 
  from flaskext.sqlalchemy import SQLAlchemy
  import settings
  
- 
  app = Flask(__name__)
  app.config['SQLALCHEMY_DATABASE_URI'] = settings.DB_URI
- app.register_module(frontend)
  
+ #Blueprint registration
+ app.register_blueprint(frontend)
+ app.register_blueprint(errors)
+ 
+ #DB intialization
  db = SQLAlchemy(app)
  
+ 
+ #Custom Error handling (move this somewhere else?)
+ @app.errorhandler(404)
+ def page_not_found(e):
+     return render_template('404.html'), 404
+ 
+ 
+ 
Switch to Blueprints, custom 404 handler.
## Code Before:
from flask import Flask
from cyclonejet.views.frontend import frontend
from flaskext.sqlalchemy import SQLAlchemy
import settings


app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = settings.DB_URI
app.register_module(frontend)

db = SQLAlchemy(app)

## Instruction:
Switch to Blueprints, custom 404 handler.
## Code After:
from flask import Flask, render_template

from cyclonejet.views.frontend import frontend
from cyclonejet.views.errors import errors

from flaskext.sqlalchemy import SQLAlchemy
import settings

app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = settings.DB_URI

#Blueprint registration
app.register_blueprint(frontend)
app.register_blueprint(errors)

#DB intialization
db = SQLAlchemy(app)


#Custom Error handling (move this somewhere else?)
@app.errorhandler(404)
def page_not_found(e):
    return render_template('404.html'), 404


