priya-zha / Software-Engineering-Project

0 stars 2 forks source link

NFR #2 If multiple requests come in simultaneously, your Flask API may not handle them properly #14

Open Manikothakota-git opened 11 months ago

Manikothakota-git commented 11 months ago

Implement proper threading or multiprocessing in your Flask application to handle concurrent requests. I imported the threading module to enable multi-threading.The process_image function now processes the image, and it returns the compressed image data. This function can be executed concurrently by multiple threads.The process_image_endpoint function is responsible for handling incoming requests. It calls the process_image function to process the image, and if successful, it returns the compressed image.With these changes, your Flask application can handle multiple requests simultaneously, improving concurrency and responsiveness.

Updated Code

import threading

Use threading to allow concurrent requests

threading.Thread(target=app.run, kwargs={'host': 'localhost', 'port': 5000}).start()