37 lines
946 B
Python
37 lines
946 B
Python
from flask import Flask
|
|
from flask_sqlalchemy import SQLAlchemy
|
|
from urllib.parse import quote_plus
|
|
import logging
|
|
|
|
db = SQLAlchemy()
|
|
|
|
logger = logging.getLogger('sqlalchemy.engine')
|
|
logger.setLevel(logging.INFO)
|
|
handler = logging.StreamHandler()
|
|
handler.setFormatter(logging.Formatter('%(asctime)s [%(levelname)s] %(message)s'))
|
|
logger.addHandler(handler)
|
|
|
|
def create_app():
|
|
app = Flask(__name__)
|
|
|
|
params = quote_plus(
|
|
"DRIVER=ODBC Driver 17 for SQL Server;"
|
|
"SERVER=NDVASQLCR01;"
|
|
"DATABASE=conradTest;"
|
|
"Trusted_Connection=yes;"
|
|
)
|
|
|
|
app.config['SQLALCHEMY_DATABASE_URI'] = f"mssql+pyodbc:///?odbc_connect={params}"
|
|
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
|
|
|
|
db.init_app(app)
|
|
|
|
from .routes import main
|
|
app.register_blueprint(main)
|
|
|
|
@app.route("/")
|
|
def index():
|
|
return "Hello, you've reached the terrible but functional root of the site."
|
|
|
|
|
|
return app
|