Skip to content

Commit

Permalink
Update __init__.py to remove legacy flask
Browse files Browse the repository at this point in the history
  • Loading branch information
cduhn17 authored Nov 22, 2024
1 parent 277548c commit 97e9044
Showing 1 changed file with 0 additions and 104 deletions.
104 changes: 0 additions & 104 deletions src/pe_reports/__init__.py
Original file line number Diff line number Diff line change
@@ -1,105 +1 @@
"""The pe_reports library."""
# We disable a Flake8 check for "Module imported but unused (F401)" here because
# although this import is not directly used, it populates the value
# package_name.__version__, which is used to get version information about this
# Python package.

# Standard Python Libraries
import logging
from logging.handlers import RotatingFileHandler
import os

# Third-Party Libraries
# from celery import Celery
from flask import Flask, render_template
from flask_login import LoginManager
from flask_migrate import Migrate
from flask_sqlalchemy import SQLAlchemy

# cisagov Libraries
from pe_reports.data.config import config

from ._version import __version__ # noqa: F401

# Stakeholder views
# from pe_reports.home.views import home_blueprint
# from pe_reports.report_gen.views import report_gen_blueprint
# from pe_reports.stakeholder.views import stakeholder_blueprint
# from pe_reports.stakeholder_bulk_upload.views import stakeholder_bulk_upload_blueprint
# from pe_reports.stakeholder_full.views import stakeholder_full_blueprint


params = config()
login_manager = LoginManager()
# Flask implementation
app = Flask(__name__)
app.config["SECRET_KEY"] = os.getenv("FLASK_SECRET_KEY", "dev")
app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
app.config[
"SQLALCHEMY_DATABASE_URI"
] = f'postgresql+psycopg2://{params["user"]}:{params["password"]}@{params["host"]}:{params["port"]}/{params["database"]}'


# Configure the redis server
# app.config["CELERY_BROKER_URL"] = "redis://localhost:6379/0"
# app.config["CELERY_RESULT_BACKEND"] = "redis://localhost:6379/0"
app.config["UPLOAD_FOLDER"] = "src/pe_reports/uploads/"
app.config["ALLOWED_EXTENSIONS"] = {"txt", "csv"}

CENTRAL_LOGGING_FILE = "pe_reports_logging.log"
DEBUG = False
# Setup Logging
"""Set up logging and call the run_pe_script function."""
if DEBUG is True:
level = "DEBUG"
else:
level = "INFO"

# Logging will rotate at 2GB
logging.basicConfig(
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
datefmt="%m/%d/%Y %I:%M:%S",
level=level,
handlers=[
RotatingFileHandler(CENTRAL_LOGGING_FILE, maxBytes=2000000, backupCount=10)
],
)

app.config["LOGGER"] = logging.getLogger(__name__)

# with open('username.txt', 'w') as file:
# file.write(pwd.getpwuid(os.getuid())[0])

# Creates a Celery object
# celery = Celery(app.name, broker=app.config["CELERY_BROKER_URL"])
# celery.conf.update(app.config)

# Config DB
db = SQLAlchemy(app)
Migrate(app, db)

# TODO: Add a login page in the future. Issue #207 contains details
# login_manager.init_app(app)
# login_manager.login_view = "login"

__all__ = ["app", "pages", "report_generator", "stylesheet"]


# Register the flask apps
# app.register_blueprint(stakeholder_blueprint)
# app.register_blueprint(stakeholder_full_blueprint)
# app.register_blueprint(stakeholder_bulk_upload_blueprint)
# app.register_blueprint(report_gen_blueprint)
# TODO: Add login blueprint. Issue #207 contains details
# app.register_blueprint(manage_login_blueprint)
# app.register_blueprint(home_blueprint)


@app.errorhandler(404)
def page_not_found(e):
return render_template("404.html")


if __name__ == "__main__":
logging.info("The program has started...")
app.run(host="127.0.0.1", debug=DEBUG, port=8000)

0 comments on commit 97e9044

Please sign in to comment.