LoginSignup
0
0

More than 1 year has passed since last update.

flaskで複数routingを同じ関数に紐つける

Posted at

個人用メモです

要点

デコレータを重ねればよい

from flask import Flask


app = Flask(__name__)


@app.route("/v1/test")
@app.route("/v2/test")
def root():
    return "<h1>Test</h1>"


if __name__ == "__main__":
    app.run(debug=True)

これで/v2/testにアクセスしたときにも/v1/testと同じものを出せる。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0