|
1 | | -from flask import Flask, render_template |
| 1 | +from flask import Flask, render_template, request |
| 2 | +import logging |
2 | 3 |
|
3 | 4 | app = Flask(__name__) |
4 | 5 |
|
| 6 | +# Set up logging |
| 7 | +logging.basicConfig(filename='error.log', level=logging.DEBUG) |
| 8 | + |
5 | 9 | @app.route('/') |
6 | 10 | def home(): |
7 | | - return render_template('home.html') |
| 11 | + try: |
| 12 | + return render_template('home.html') |
| 13 | + except Exception as e: |
| 14 | + app.logger.error(f"Error rendering home.html: {e}") |
| 15 | + return "Internal Server Error", 500 |
8 | 16 |
|
9 | 17 | @app.route('/about') |
10 | 18 | def about(): |
11 | | - return render_template('about.html') |
| 19 | + try: |
| 20 | + return render_template('about.html') |
| 21 | + except Exception as e: |
| 22 | + app.logger.error(f"Error rendering about.html: {e}") |
| 23 | + return "Internal Server Error", 500 |
12 | 24 |
|
13 | 25 | @app.route('/projects') |
14 | 26 | def projects(): |
15 | | - return render_template('projects.html') |
| 27 | + try: |
| 28 | + return render_template('projects.html') |
| 29 | + except Exception as e: |
| 30 | + app.logger.error(f"Error rendering projects.html: {e}") |
| 31 | + return "Internal Server Error", 500 |
16 | 32 |
|
17 | 33 | @app.route('/contact') |
18 | 34 | def contact(): |
19 | | - return render_template('contact.html') |
| 35 | + try: |
| 36 | + return render_template('contact.html') |
| 37 | + except Exception as e: |
| 38 | + app.logger.error(f"Error rendering contact.html: {e}") |
| 39 | + return "Internal Server Error", 500 |
20 | 40 |
|
21 | 41 | if __name__ == '__main__': |
22 | 42 | app.run(debug=True) |
0 commit comments