-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Virtual environment working, user database restored and queried
- Loading branch information
1 parent
63ac7ce
commit 2ea955e
Showing
4 changed files
with
47 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,60 @@ | ||
from flask import Flask | ||
from config import Config #import the Config class from config.py | ||
# This file is the package constructor for the app package. | ||
from flask import Flask | ||
from config import Config # import the Config class from config.py | ||
from flask_sqlalchemy import SQLAlchemy | ||
from flask_migrate import Migrate | ||
|
||
from flask_login import LoginManager | ||
import logging | ||
from logging.handlers import SMTPHandler | ||
from logging.handlers import RotatingFileHandler | ||
import os | ||
from flask_mail import Mail | ||
|
||
app = Flask(__name__) # Create an instance of the Flask class | ||
app.config.from_object(Config)# Load the configuration | ||
app = Flask(__name__) # Create an instance of the Flask class | ||
app.config.from_object(Config) # Load the configuration | ||
db = SQLAlchemy(app) | ||
migrate = Migrate(app, db) | ||
login = LoginManager(app) | ||
login.login_view = 'login' | ||
login.login_view = "login" | ||
mail = Mail(app) | ||
|
||
if not app.debug: | ||
if app.config['MAIL_SERVER']: | ||
if app.config["MAIL_SERVER"]: | ||
auth = None | ||
if app.config['MAIL_USERNAME'] or app.config['MAIL_PASSWORD']: | ||
auth = (app.config['MAIL_USERNAME'], app.config['MAIL_PASSWORD']) | ||
if app.config["MAIL_USERNAME"] or app.config["MAIL_PASSWORD"]: | ||
auth = (app.config["MAIL_USERNAME"], app.config["MAIL_PASSWORD"]) | ||
secure = None | ||
if app.config['MAIL_USE_TLS']: | ||
if app.config["MAIL_USE_TLS"]: | ||
secure = () | ||
mail_handler = SMTPHandler( | ||
mailhost=(app.config['MAIL_SERVER'], app.config['MAIL_PORT']), | ||
fromaddr='no-reply@' + app.config['MAIL_SERVER'], | ||
toaddrs=app.config['ADMINS'], subject='Plantseedscook Failure', | ||
credentials=auth, secure=secure) | ||
mailhost=(app.config["MAIL_SERVER"], app.config["MAIL_PORT"]), | ||
fromaddr="no-reply@" + app.config["MAIL_SERVER"], | ||
toaddrs=app.config["ADMINS"], | ||
subject="Plantseedscook Failure", | ||
credentials=auth, | ||
secure=secure, | ||
) | ||
mail_handler.setLevel(logging.ERROR) | ||
app.logger.addHandler(mail_handler) | ||
if not os.path.exists('logs'): | ||
os.mkdir('logs') # create a directory called logs | ||
|
||
if not os.path.exists("logs"): | ||
os.mkdir("logs") # create a directory called logs | ||
# RotatingFileHandler is used to save the log messages to a file | ||
file_handler = RotatingFileHandler('logs/plantseedscook.log', maxBytes=10240, backupCount=10) | ||
file_handler.setFormatter(logging.Formatter( # set the format of the log messages | ||
'%(asctime)s %(levelname)s: %(message)s [in %(pathname)s:%(lineno)d]')) | ||
file_handler = RotatingFileHandler( | ||
"logs/plantseedscook.log", maxBytes=10240, backupCount=10 | ||
) | ||
file_handler.setFormatter( | ||
logging.Formatter( # set the format of the log messages | ||
"%(asctime)s %(levelname)s: %(message)s [in %(pathname)s:%(lineno)d]" | ||
) | ||
) | ||
file_handler.setLevel(logging.INFO) | ||
app.logger.addHandler(file_handler) | ||
|
||
app.logger.setLevel(logging.INFO) | ||
app.logger.info('Plantseedscook startup') | ||
app.logger.info("Plantseedscook startup") | ||
|
||
from app import routes, models, errors | ||
|
||
# Flask-SQLAlchemy and Flask-Migrate initialization | ||
# Flask-SQLAlchemy and Flask-Migrate initialization |
Binary file not shown.