Flask URL Route: Route All other URLs to some function

  1. I think this is the answer http://flask.pocoo.org/docs/design/#the-routing-system
  2. If you need to handle all urls not found on server — just create 404 hanlder:

    @app.errorhandler(404)
    def page_not_found(e):
        # your processing here
        return result
    

This works for your second issue.

from flask import Flask

app = Flask(__name__)

@app.route('/')
def index():
    return 'This is the front page'

@app.route('/hello/')
def hello():
    return 'This catches /hello'

@app.route('/')
@app.route('/<first>')
@app.route('/<first>/<path:rest>')
def fallback(first=None, rest=None):
    return 'This one catches everything else'

path will catch everything until the end. More about the variable converters.