Git Product home page Git Product logo

flask-202-flow's Introduction

flask-202-flow

Illustration of a Flask endpoint which continues to run code after a 202 response is sent to the client.

# host HTTP server #
gunicorn --bind :5000 --workers 1 --threads 4 --timeout 30 main:app
# send a request #
curl --request POST \
'http://localhost:5000/202_flow_example?wait_n_secs_after_response=10'
Endpoint Response:  ACCEPTED (202) at 20:56:54.379
2023-11-27 20:56:54,380 INFO started after response code
2023-11-27 20:56:55,385 INFO waited 1 seconds
2023-11-27 20:56:56,390 INFO waited 2 seconds
2023-11-27 20:56:57,394 INFO waited 3 seconds
2023-11-27 20:56:58,399 INFO waited 4 seconds
2023-11-27 20:56:59,403 INFO waited 5 seconds
2023-11-27 20:57:00,408 INFO waited 6 seconds
2023-11-27 20:57:01,411 INFO waited 7 seconds
2023-11-27 20:57:02,417 INFO waited 8 seconds
2023-11-27 20:57:03,420 INFO waited 9 seconds
2023-11-27 20:57:04,423 INFO waited 10 seconds
2023-11-27 20:57:04,427 INFO finished waiting 10 seconds

A request not generating a 202 response will not run the after response code:

# send a request #
curl --request POST \
'http://localhost:5000/202_flow_example?wait_n_secs_after_response=99999'
Endpoint Response:  FORBIDDEN (403) at 20:58:45.598

flask-202-flow's People

Contributors

j-sephb-lt-n avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.