mirror of
https://github.com/github/codeql.git
synced 2026-04-30 19:26:02 +02:00
Python: Add tests for flask blueprints
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
import flask
|
||||
|
||||
bp3 = flask.Blueprint("bp3", __name__)
|
||||
|
||||
@bp3.route("/bp3/example") # $ MISSING: routeSetup="/bp3/example"
|
||||
def bp3_example(): # $ MISSING: requestHandler
|
||||
return "bp 3 example"
|
||||
@@ -93,5 +93,32 @@ class WithoutKnownRoute2(MethodView):
|
||||
pass
|
||||
|
||||
|
||||
# Blueprints
|
||||
#
|
||||
# see https://flask.palletsprojects.com/en/1.1.x/blueprints/
|
||||
|
||||
bp1 = flask.Blueprint("bp1", __name__)
|
||||
|
||||
@bp1.route("/bp1/example/<foo>") # $ MISSING: routeSetup="/bp1/example/<foo>"
|
||||
def bp1_example(foo): # $ MISSING: requestHandler routedParameter=foo
|
||||
return "bp 1 example foo={}".format(foo)
|
||||
|
||||
app.register_blueprint(bp1) # by default, URL of blueprints are not changed
|
||||
|
||||
|
||||
bp2 = flask.Blueprint("bp2", __name__)
|
||||
|
||||
@bp2.route("/example") # $ MISSING: routeSetup="/example"
|
||||
def bp2_example(): # $ MISSING: requestHandler
|
||||
return "bp 2 example"
|
||||
|
||||
app.register_blueprint(bp2, url_prefix="/bp2") # but it is possible to add a url_prefix
|
||||
|
||||
|
||||
from external_blueprint import bp3
|
||||
app.register_blueprint(bp3)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
print(app.url_map)
|
||||
app.run(debug=True)
|
||||
|
||||
Reference in New Issue
Block a user