Performance: File upload processing
MEDIUM IMPACT
This affects page load speed and interaction responsiveness by how the server handles file uploads and how the frontend manages upload UI and feedback.
from flask import Flask, request import threading import os app = Flask(__name__) def save_file_async(data, filename): with open(os.path.join('/tmp', filename), 'wb') as f: f.write(data) @app.route('/upload', methods=['POST']) def upload(): file = request.files['file'] filename = file.filename data = file.read() threading.Thread(target=save_file_async, args=(data, filename)).start() return 'Upload started'
from flask import Flask, request app = Flask(__name__) @app.route('/upload', methods=['POST']) def upload(): file = request.files['file'] file.save('/tmp/' + file.filename) return 'Upload complete'
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Synchronous file save in Flask route | Minimal DOM changes | 0 reflows | Low paint cost | [X] Bad |
| Asynchronous file save with background thread | Minimal DOM changes | 0 reflows | Low paint cost | [OK] Good |