jalexray / jacob-jam

MIT License
0 stars 0 forks source link

Jacob Jam

This is a playground repository to test and demo Jacob.

Flask Application Structure

This application is built using Flask, a lightweight WSGI web application framework. It follows a modular structure using Flask Blueprints for organizing routes and templates.

Routes Organization

Routes are defined in /app/main/routes.py using Flask Blueprints. The main blueprint is initialized in /app/main/__init__.py:

from flask import Blueprint bp = Blueprint('main', name)

Current routes in the application:

Templates Usage

Templates are stored in the /app/templates/ directory and are rendered using Flask's render_template function. The application uses Jinja2 templating engine for dynamic content rendering.

Current templates:

Adding a New Route and Template

To add a new route and template to the application:

  1. Create a new template file in /app/templates/:

    {% extends "base.html" %} {% block content %}

    {% endblock %}

  2. Add a new route in /app/main/routes.py: @bp.route('/new-page', methods=['GET']) def new_page(): return render_template('new_page.html', title='New Page')

Best Practices

  1. Route Naming

    • Use lowercase for route URLs
    • Separate words with hyphens
    • Keep URLs descriptive but concise
  2. Template Organization

    • Use template inheritance with base.html
    • Keep templates in the appropriate directory
    • Use meaningful template names
  3. Route Implementation

    • Always specify allowed HTTP methods
    • Include appropriate error handling
    • Pass necessary context to templates
  4. Error Handling

    • Custom error pages are handled through error handlers
    • Error templates should extend the base template
    • Include helpful error messages and navigation options