Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

Redirecting an old URL to a new one with Flask micro-framework

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)
Comment

PREVIOUS NEXT
Code Example
Python :: Python beginner question - trying to understand return statement 
Python :: Determining the Data Type 
Python :: session timeout flask 
Python :: jsfakjfkjadjfksajfa 
Python :: get command line variables python 
Python :: Evaluate mathematical expression 
Python :: dataframe get missing and zero values 
Python :: flask login attemted_user cant see check_password_correction method 
Python :: get the first principle component of pca 
Python :: ring Delete Item From List 
Python :: ring write the key and the IV directly using strings 
Python :: hacer un programa en python ingresar números enteros obtenga el segundo valor máximo 
Python :: pandas rolling list 
Python :: how to start spaCy code 
Python :: update a variable in torch 
Python :: Proper Case django template 
Python :: python message from byte 
Python :: output of an intermediate layer 
Python :: python save base64 temp file 
Python :: phobia of butterflies 
Python :: default python structure 
Python :: revit dynamo select all categories 
Python :: reverse row order padnas 
Python :: multiplication table in python 
Python :: rename column in dataframe 
Python :: ‘A’, ‘Q’, ‘BM’, ‘BA’, ‘BQ’ meaning in resample 
Python :: pandas melt and stack 
Python :: give access to normal user like super user 
Python :: A Simple Class 
Python :: Create Tables From Migration 
ADD CONTENT
Topic
Content
Source link
Name
6+3 =