from flask import Flask from werkzeug import redirect from flask.helpers import url_for app = Flask(__name__) @app.route('/') def Index(): return "Index Page" @app.route('/hello') def hello(): return "Hello World!" @app.route('/hello/<username>') def Hi(username): return "Hi %s" % username @app.route('/post/<int:post_id>') def postid(post_id): return "post_id: %d" %post_id @app.route('/path/<path:subpath>') def show_subpath(subpath): return "Path %s" % subpath @app.route('/message/') def message1(): return 'Redirect to another web Page!' @app.route('/jump/') def show_url(): return redirect( url_for('message1')) @app.route('/test/') def test_url_for(): #return 'Hi %s!' % name return redirect(url_for('Hi', username='GreyLi')) if __name__=="__main__": app.run(port=888)