Created
August 13, 2019 17:36
-
-
Save MohiuddinAkib/5ef9983fea59cc737ce8b0c1badeb57d to your computer and use it in GitHub Desktop.
Handling any route with python flask
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import Flask, render_template, abort | |
from jinja2 import TemplateNotFound | |
@app.route('/', defaults={'path': ''}) | |
@app.route('/<path:path>') | |
def index(path): | |
try: | |
return render_template('index.html') | |
except TemplateNotFound: | |
abort(404) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment