Skip to content
Snippets Groups Projects
myFlaskProject.py 987 B
Newer Older
  • Learn to ignore specific revisions
  • from flask import Flask, render_template, request
    
    app = Flask(__name__, template_folder='./templates')
    
    @app.route("/")
    def index():
    
    @app.route("/list.html", methods=['GET', 'POST'])
    
        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(data, 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)
    
    @app.route("/project/<int:project_id>")
    def project_details(project_id):
        project = get_project(data, project_id)
        if project:
            return render_template('project_details.html', project=project)
        else:
            return "Project not found", 404
    
    if __name__ == "__main__":
        app.run(debug=True)