Mengarahkan ulang URL lama ke yang baru dengan kerangka mikro labu

from flask import Flask, redirect, request

app = Flask(__name__)

redirect_urls = {
    'http://example.com/old/': 'http://example.com/new/',
    ...
}

def redirect_url():
    return redirect(redirect_urls[request.url], 301)

for url in redirect_urls:
    app.add_url_rule(url, url, redirect_url)
SAMER SAEID