Skip to content

Commit

Permalink
new: [webiste] query+config
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidCruciani committed Feb 7, 2024
1 parent b5b9d8d commit 2fe44f2
Show file tree
Hide file tree
Showing 2,196 changed files with 144,357 additions and 0 deletions.
5 changes: 5 additions & 0 deletions webiste/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# PetitCrolle

Tool that help conducting a forensic analysis by providing a regroupement of tools in one place

<img title="MarkText logo" src="file:///home/dacru/Desktop/Git/PetitCrolle/doc/crolle.png" alt="Alt text" width="388" data-align="center">
38 changes: 38 additions & 0 deletions webiste/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
from app import create_app, db
import argparse
from flask import render_template
import os
from app.utils.init_modules import create_modules_db


parser = argparse.ArgumentParser()
parser.add_argument("-i", "--init_db", help="Initialise the db if it not exist", action="store_true")
parser.add_argument("-r", "--recreate_db", help="Delete and initialise the db", action="store_true")
parser.add_argument("-d", "--delete_db", help="Delete the db", action="store_true")
parser.add_argument("-m", "--create_module", help="Create modules in db", action="store_true")
args = parser.parse_args()

os.environ.setdefault('FLASKENV', 'development')

app = create_app()

@app.errorhandler(404)
def error_page_not_found(e):
return render_template('404.html'), 404


if args.init_db:
with app.app_context():
db.create_all()
elif args.recreate_db:
with app.app_context():
db.drop_all()
db.create_all()
elif args.delete_db:
with app.app_context():
db.drop_all()
elif args.create_module:
with app.app_context():
create_modules_db()
else:
app.run(host=app.config.get("FLASK_URL"), port=app.config.get("FLASK_PORT"))
30 changes: 30 additions & 0 deletions webiste/app/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from flask_wtf import CSRFProtect
from flask_migrate import Migrate

from config import config as Config
import os


db = SQLAlchemy()
csrf = CSRFProtect()
migrate = Migrate()

def create_app():
app = Flask(__name__)
config_name = os.environ.get("FLASKENV")

app.config.from_object(Config[config_name])

Config[config_name].init_app(app)

db.init_app(app)
csrf.init_app(app)
migrate.init_app(app, db, render_as_batch=True)

from .home import home_blueprint
app.register_blueprint(home_blueprint, url_prefix="/")

return app

Loading

0 comments on commit 2fe44f2

Please sign in to comment.