Navbar

TROUBLESHOOTING STANDARDS

Flask HTML Application - Systematic Problem Solving

CRITICAL RULE: NO CODING UNTIL YOU LOCATE THE ISSUE

  • Never start with "ready, fire, aim" approach
  • Investigate thoroughly before making changes
  • Document your findings before proposing solutions
  • Ask if the problem is worth fixing vs. creating new

TROUBLESHOOTING PROCESS

STEP 1: IDENTIFY THE PROBLEM LOCATION

Given a URL showing an issue, locate all relevant files:

  • URL: https://domain.com/path
  • Route: Search in front_routes_blueprint.py for matching route
  • Template: Identify template from route handler (e.g., render_template('file.html'))
  • Static files: Check /static/html/ directory if needed
File Location Commands:
grep -n "@front.route('/path')" front_routes_blueprint.py
find . -name "*.html" | grep template_name
ls -la /var/www/html/modular.nsgia.com/static/html/

STEP 2: VERIFY FILE SYSTEM ACCESS

Check that files exist and are accessible:

  • Template path: /var/www/html/modular.nsgia.com/front/templates/
  • Static HTML path: /var/www/html/modular.nsgia.com/static/html/
  • File permissions: Readable by web server
  • File contents: Valid HTML structure
File System Checks:
ls -la /path/to/template
head -20 /path/to/file.html
file /path/to/file.html

STEP 3: DOCUMENT THE ISSUE

Clearly define what's wrong:

  • Expected behavior: What should happen?
  • Actual behavior: What is happening?
  • Error messages: Console, browser, or Flask logs
  • Issue type: Missing feature vs. broken functionality

STEP 4: ADD DEBUG OUTPUT

If no errors are visible, add debug prints to routes:

  • Add print statements at function start
  • Print variable values at each logical step
  • Verify template variables are passed correctly
  • Check file paths and existence
Debug Pattern for Routes:
print(f"DEBUG: route_name - Starting at {datetime.now()}")
print(f"DEBUG: route_name - Variable value: {variable}")
print(f"DEBUG: route_name - File path: {file_path}")
print(f"DEBUG: route_name - File exists: {os.path.exists(file_path)}")

DECISION TREE: FIX OR REPLACE?

Before Coding, Ask:

  1. Is this adding a new feature?
    • Yes → Add to existing code if it's clean
    • No → Assess if it's actually broken
  2. Is the existing code a mess?
    • Yes → Create new blueprint/route
    • No → Fix the specific issue
  3. Is it complex to debug?
    • Yes → Sometimes better to rewrite cleanly
    • No → Fix systematically
  4. Is it throwing errors?
    • No → Add debug prints first
    • Yes → Fix the error

COMMON FLASK HTML ISSUES

Template Not Found

Static Files Not Loading

Route Not Working

Template Variables Missing

INVESTIGATION CHECKLIST

Before making any changes:

REMEMBER