zoukankan      html  css  js  c++  java
  • flask路由

    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)
    

      

  • 相关阅读:
    初步认识,合并集(树)
    20180918-1 词频统计
    20181011-1 每周例行报告
    2018091-2 博客作业
    项目第六天
    项目第五天
    项目第四天
    项目第三天
    总结随笔
    测试报告
  • 原文地址:https://www.cnblogs.com/luoye00/p/11976313.html
Copyright © 2011-2022 走看看