flask - How can I call a specific function based on url in python web frameworks? -


this question has answer here:

i have developed python application takes in post variables , inserts data postgresql. want call specific function when call url.

for example

if    curl -i http://127.0.0.1:5000/abc/cde   should call     def aaa()   if curl -i http://127.0.0.1:5000/pqr/xyz   should call    def bbb() 

is there way achieve in python flask web frameworks ?

this 1 of main features of web framework. minimal example in flask be:

# my_app.py  flask import flask app = flask(__name__)  @app.route('/abc/cde') def aaa():     return 'hello, aaa'  @app.route('/pqr/xyz') def bbb():     return 'hello, bbb'  if __name__ == '__main__':     app.run() 

you can run this:

$ python my_app.py

like python script. suggest have @ flask's quickstart page starting point.


Comments

Popular posts from this blog

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

php - render data via PDO::FETCH_FUNC vs loop -

The canvas has been tainted by cross-origin data in chrome only -