擅长:python、mysql、java
<p>你需要使用烧瓶重定向</p>
<p>烧瓶重定向(位置,代码=302)</p>
<blockquote>
<p>Return a response object (a WSGI application) that, if called,
redirects the client to the target location. Supported codes are 301,
302, 303, 305, and 307. 300 is not supported because it’s not a real
redirect and 304 because it’s the answer for a request with a request
with defined If-Modified-Since headers.</p>
<p>Parameters:<br/>
location – the location the response should redirect to.
code – the redirect status code. defaults to 302.</p>
</blockquote>
<p>示例代码:</p>
<pre><code>import os
from flask import Flask,redirect
app = Flask(__name__)
@app.route('/')
def hello():
return redirect("http://www.example.com", code=302)
if __name__ == '__main__':
# Bind to PORT if defined, otherwise default to 5000.
port = int(os.environ.get('PORT', 5000))
app.run(host='0.0.0.0', port=port)
</code></pre>
<p>见<a href="http://flask.pocoo.org/docs/0.10/api/#flask.redirect" rel="nofollow">the documentation on flask docs</a>。</p>