forked from RodolfoFerro/Flask101
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapp.py
More file actions
37 lines (24 loc) · 719 Bytes
/
app.py
File metadata and controls
37 lines (24 loc) · 719 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import yaml
from flask import Flask
from flask import request
from flask import render_template
# Create a Flask app instance
app = Flask(__name__)
@app.route('/')
def index():
"""Base route."""
return render_template('index.html')
@app.route('/material')
def material():
"""Route for material section."""
with open('material.json', 'r') as file:
data = file.read()
material = yaml.load(data)
return render_template('material.html', material=material)
@app.errorhandler(404)
def not_found(error=None):
"""Error handling route (404)."""
return render_template('404.html', url=request.url)
if __name__ == '__main__':
# app.run(debug=True, port=8000)
app.run()