Skip to content

Instantly share code, notes, and snippets.

@MohiuddinAkib
Created August 13, 2019 17:36
Show Gist options
  • Save MohiuddinAkib/5ef9983fea59cc737ce8b0c1badeb57d to your computer and use it in GitHub Desktop.
Save MohiuddinAkib/5ef9983fea59cc737ce8b0c1badeb57d to your computer and use it in GitHub Desktop.
Handling any route with python flask
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