<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                # 104 Flask-Restful插件的基本使用 ## 安裝 ```text pip install flask-restful ``` ## 定義Restful的視圖 使用flask-restful,那么定義視圖函數的時候,就要繼承自flask\_restful.Resource類,然后再根據當前請求的method來定義相應的方法。比如期望客戶端是使用get方法發送過來的請求,那么就定義一個get方法。類似于MethodView。 ```text from flask import Flask,render_template,url_for from flask_restful import Api,Resource app = Flask(__name__) # 用Api來綁定app api = Api(app) # Json數據 class IndexView(Resource): def get(self,username=None): return {"username":"angle"} # 可以指定多個url api.add_resource(IndexView,'/index/<username>/','/regist/',endpoint='index') with app.test_request_context(): print(url_for('index',username='angle')) if __name__ == '__main__': app.run(debug=True) ``` 注意事項: 1. endpoint是用來給url\_for反轉url的時候指定的。如果不寫endpoint,那么將會使用視圖的名字的小寫作為endpoint。 2. add\_resource的第二個參數是訪問這個視圖函數的url,這個url可以跟之前的route一樣,可以傳遞參數,并且還有一點不同的是,這個方法可以傳遞多個url來指定這個視圖函數
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看