Skip to content

Instantly share code, notes, and snippets.

@fastjack
Created May 22, 2024 17:19
Show Gist options
  • Save fastjack/b82b0905fe9eae9b6ca041de2777bd3e to your computer and use it in GitHub Desktop.
Save fastjack/b82b0905fe9eae9b6ca041de2777bd3e to your computer and use it in GitHub Desktop.
Init of flask app (replace : with / in filename)
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
database = SQLAlchemy()
class Application:
def __init__(self, port: int = 5000, debug: bool = True):
self.port: int = port
self.debug: bool = debug
self.db = database
self.app = Flask(__name__)
self.app.config['SECRET_KEY'] = 'REDACTED'
self.app.config['TEMPLATES_AUTO_RELOAD'] = True
self.app.config['SQLALCHEMY_DATABASE_URI'] = 'REDACTED'
self.db.init_app(self.app)
def init_routes(self):
from application.routes import home
self.app.register_blueprint(home)
def run(self):
self.init_routes()
Flask.run(self.app, port=self.port, debug=self.debug, host='127.0.0.1')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment