Skip to content

Commit

Permalink
Virtual environment working, user database restored and queried
Browse files Browse the repository at this point in the history
  • Loading branch information
Gil-Gaitan committed Feb 14, 2025
1 parent 63ac7ce commit 2ea955e
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 21 deletions.
16 changes: 16 additions & 0 deletions MAIN.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
# MAIN.md Documentation for Branch Development

## 02/13/25 - Kickstarting it back up, address email routing
Review instructions to run:
- Load Virtual Environment
'''source venv/bin/activate
-Run App
'''flask run --port 5001

'''flask db init???

Database: Flask-SQLAlchemy, Flask-Migrate
user: id, username, email, password_hash - found in app/models.py

To access and read data:



## 11/05/24 - Postmark Feature
- Signed up for postmark.
- There are basic instructions in settings. Login info saved in cloud note.
Expand Down
Binary file modified app.db
Binary file not shown.
52 changes: 31 additions & 21 deletions app/__init__.py
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 modified app/__pycache__/__init__.cpython-312.pyc
Binary file not shown.

0 comments on commit 2ea955e

Please sign in to comment.