flask 中 redirect 方法可以重镜像地址。



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author: wxnacy([email protected])

from flask import Flask
from flask import redirect
from flask import url_for

app = Flask(__name__)

@app.route('/baidu')
def bd():
'''重镜像'''
return redirect('http://baidu.com')

@app.route('/')
def index():
'''获取路由地址,并重镜像'''
return redirect(url_for('bd'))
03-17 03:17