Skip to content

Commit

Permalink
Corrected tempalte error in 404 and 500 error templates.
Browse files Browse the repository at this point in the history
  • Loading branch information
ddeveloper72 committed May 2, 2019
1 parent c35147d commit 6768dfa
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 22 deletions.
47 changes: 27 additions & 20 deletions run.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,72 +5,79 @@
app = Flask(__name__)
app.secret_key = 'some_secret'


@app.route('/')
def index():
return render_template("index.html")


@app.route('/git')
def git():
return render_template("git.html", page_title="Git Profile")




@app.route('/contact')
def contact():
if request.method == "POST":
flash("Thanks {}, we have received your message!".format(
request.form["name"]))
return render_template("contact.html", page_title="Contact")
return render_template("contact.html", page_title="Contact")


@app.route('/work')
def work():
data = []
with open("data/work.json", "r") as json_data:
data = json.load(json_data)
return render_template("work.html", page_title="Experience", work_data = data)
return render_template("work.html", page_title="Experience",
work_data=data)


@app.route('/work/<experience_name>')
def about_experience(experience_name):
experience = {}

return render_template("work.html", experience = experience)
return render_template("work.html", experience=experience)


@app.route('/education')
def education():
data = []
with open("data/school.json", "r") as json_data:
with open("data/school.json", "r") as json_data:
data = json.load(json_data)

return render_template("education.html", page_title="Education", school_data = data)

return render_template("education.html", page_title="Education",
school_data=data)


@app.route('/education/<education_name>')
def about_education(education_name):
education = {}

return render_template("education.html", education = education)

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
# Page not found 404 Views #
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
return render_template("education.html", education=education)


# Page not found 404 Views


@app.errorhandler(404)
def not_found(error):
def page_not_found(error):
"""
Inbuilt function which takes error as parameter
Inbuilt function which takes error as parameter
"""
return render_template("404.html"), 404

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
# Internal Error Views #
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#

# Internal Error Views


@app.errorhandler(500)
def internal_error(error):
def special_exception_handler(error):
"""
Inbuilt function which takes error as parameter
"""
return render_template("500.html")
return render_template("500.html"), 500

if __name__ == '__main__':
app.run(host=os.getenv('IP'),
Expand Down
2 changes: 1 addition & 1 deletion templates/404.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<div class="container mt-5 text-center">
<div class="row">
<div class="col-sm-12">
<a href="{{ url_for('appointment') }}"><img class="img-fluid" src="{{ url_for('static', filename='images/404error.jpeg')}}" alt="404 page not found"></a>
<a href="{{ url_for('index') }}"><img class="img-fluid" src="{{ url_for('static', filename='img/404error.jpeg')}}" alt="404 page not found"></a>
</div>
<div class="col-sm-12 mt-3">
<p class="lost">What you were looking for is just not there...</p>
Expand Down
2 changes: 1 addition & 1 deletion templates/500.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<div class="container mt-5 text-center">
<div class="row">
<div class="col-sm-12">
<a href="{{ url_for('appointment') }}"><img class="img-fluid" src="{{ url_for('static', filename='images/500error.jpg')}}" alt="500 server error"></a>
<a href="{{ url_for('index') }}"><img class="img-fluid" src="{{ url_for('static', filename='img/500error.jpg')}}" alt="500 server error"></a>
</div>
<div class="col-sm-12 mt-3">
<p class="lost">It looks like there has been a server error...</p>
Expand Down

0 comments on commit 6768dfa

Please sign in to comment.