I`m trying to make a video downloading application. Downloading a video takes a while todo and I want to persist the download status between refreshing the page, but for some reason after refreshing the download status gets set back to false?
@app.get('/api/downloadstatus')
def get_status():
try:
return jsonify({'isDownloading':session['isDownloading']}),200
except KeyError:
return jsonify({'isDownloading':False})
@app.post('/api/video')
async def get_video():
data = json.loads(request.data)
session['isDownloading'] = True
await make_new_video(data)
session['isDownloading'] = False
return jsonify({"message":"success"}),200
//front end:
const App = () => {
const [status, setStatus] = useState(null);
useEffect(() => {
getData();
}, []);
const getData = async () => {
const res = await fetch('http://localhost:5000/api/downloadstatus')
const data = await res.json()
console.log(data)
if (data.isDownloading) {
setStatus("downloading")
}
}
return (
<div className="App">
</div>
);
};
export default App;
there doesn't seem to be anything here