Astik Gabani
Astik Gabani

Reputation: 605

Create flask endpoint only for testing

I am learning flask to create endpoints using flask-restful and flask-sqlalchemy.

There is one configuration property named testing in the flask.

Is there any way in flask-restful or in the flask, using that we can create an endpoint that will only available if testing config property of flask app is true.

Upvotes: 0

Views: 297

Answers (1)

Dave W. Smith
Dave W. Smith

Reputation: 24966

Take advantage of the flexibility that Python provides.

if app.testing:
    @app.route('/only-for-testing')
    def only_for_testing():
        ...

Upvotes: 2

Related Questions