Newer
Older

Oliwer Mattsson
committed
from flask import Flask, render_template, request

Oliwer Mattsson
committed
from data import *

Oliwer Mattsson
committed
app = Flask(__name__, template_folder='./templates')

Oliwer Mattsson
committed
data = load('data.json')
@app.route("/")
def index():

Oliwer Mattsson
committed
return render_template('index.html')
@app.route("/list", methods=['GET', 'POST'])

Oliwer Mattsson
committed
def list():

Oliwer Mattsson
committed
search_query = request.form.get('search', '')
sort_by = request.form.get('sort_by', 'start_date')
sort_order = request.form.get('sort_order', 'desc')
filtered_projects = search(load('data.json'), sort_by=sort_by, sort_order=sort_order, search=search_query)
return render_template('list.html',
projects=filtered_projects,
search_query=search_query,
sort_by=sort_by,
sort_order=sort_order)

Oliwer Mattsson
committed
@app.route("/project/<int:project_id>")
def project_details(project_id):
project = get_project(load('data.json'), project_id)

Oliwer Mattsson
committed
if project:
return render_template('project_details.html', project=project)
else:
return "404: Project not found", 404
@app.route("/techniques", methods=['GET', 'POST'])
def techniques():
techniques = get_technique_stats(load('data.json'))
search_query = request.form.get('search', '')
sort_by = request.form.get('sort_by', 'start_date')
sort_order = request.form.get('sort_order', 'desc')
search_field = request.form.getlist('search_field', None)
techniques_search = request.form.getlist('technique')
print(f"Searching for: ", search_query)
filtered_projects = search(load('data.json'), sort_by=sort_by, sort_order=sort_order, techniques=techniques_search, search=search_query, search_fields=search_field)
return render_template('techniques.html',
techniques = techniques,
techniques_search = techniques_search,
projects=filtered_projects,
search_query=search_query,
sort_by=sort_by,
sort_order=sort_order,
search_field=search_field)

Oliwer Mattsson
committed
if __name__ == "__main__":
app.run(debug=True)