 So you have some parameters. When you had to generate plot, it will go to ECG, send an API post request with the parameters that wouldn't work. It was trying to generate a separate chat in a separate HTML. And now we put them back to Giver. So that should be the index HTML now in a Python code. We should be calling index HTML image redirect. No, so we don't want to redirect. We want to stay on the same page. And we have generate ECG plot. OK, we'll need JSON5 from Flask instead of redirect so that error message is gone. But we still have the generate plot. It keeps also saying that I do not need JavaScript for whatever reason. Did a few updates. You can also read the plot image directly in the same page using Flanks and Ginger. So I think we're OK using JSON5. So we're OK using this code. It's just that, right, so it looks like you're trying to integrate both approaches sending JSON as a file. Yes, we need to get rid of some stuff. I think we might need JavaScript later. Can we modify the whole code to include a script.js? Let's see what it does. Use JavaScript, jQuery, simplicity, and all the submissions and update the image on the page without requiring full page refresh. That's good. Yeah, we don't want full page request every refresh. Right, now it's updating all the files. It says all the code here remains the same. Not sure I have that bit. OK, we have a JavaScript as well, whatever that does. Just check that we have the correct file. The previous one wasn't working. It also might as well get rid of it. HTML. We can get rid of that copy. Yep, that looks OK. We have 54 lines. We have 40. I assume it knows we only have one file. Right, so we're using JSON5. That's great. Why we saving figure? What's the alternative to saving the figure? Instead of saying figure, you can convert the port directly to page 64, string using mudplotlib, printfigure method. What did we use for previous applications? So far we have the ECG signal generator. It's working quite well. So we do like that. That was using ECG and was using NumPy into JSON. Is it possible not to save the figure to file at all? Save the figure to bytes. Oh, buffer in memory. Save the figure, code, the buffer, score this. The plot not saved to file on disk, but this directly converted to page 64, string. Everything happens in memory. Memory in the browser? No, to the server. So I'm the server. So it is saving to file when generating a plot using the approach I described. The plot is not saved to a physical file. Instead, temporary is stored in server's RAM. But I don't want to use RAM. Do I want to use RAM? The binary router is then encoded into 64. Send to the client browser for display. Is it possible to render on the client's side? Server load, it can reduce the load on the server. It allows real-time interaction. That's nice. Not all browsers or devices may sport their required technologies. So there's generally a compromise between me doing most of the server, which I have to pay electricity for, or using your browser. So you pay the electricity bill. So guess what my first choice would be. So we're processing on the client's side. Yeah, so this is more similar to the previous application that we had. OK, can you? We're processing on the client's side. Generate HTML. We'll do some processing on the server and some on the client's side. All the maps, the calculation, should be done on the server and rendering of the chart would be done in the browser using JavaScript. Yeah, so the last application is the Python script is using JSON. It's generating the data, sending it to the client's side and JavaScript and does all the plotting. It's using both plotly jQuery and JavaScript. That's fine. OK, let's update this. Might as well get rid of it. So eventually it will be similar to this application, except that we'll have the different components of the ECG waveform labeled. Now with different colors or just dots on the peaks and troughs for the PQRST, it should look like something like that. No idea what happened there, but there is some noise variability in it, obviously. Still labeling. Yeah, those are a bit off, so we'll have to correct them later. OK, so we can flask server handle the ECG data generation and processing. That's right. Next HTML. Ooh, no, no, no, no. Wait a second. What have changed this file? OK, we'll save that to check if it's working again. Right, that's the working thing now in there. Our application, this should be just a template. There's no major errors here. HTML, no major errors there. JavaScript used to be 25 lines of code. That's 35. OK, let's see if we run this. OK, so first, let's see if we have the plot So that's the form. That's the plot. You can barely see it. It's almost not there. We'll make it with bonus act. Generating ECG gets a 500 there. All right, this is why. So we're essentially missing calculations in there. And it's OK that it can stop generating. Let's take sure problem is here. There are integers already, aren't there? It doesn't really matter because we don't have the calculation. The calculation should be in this Python code. OK, we have the code in here that does the calculation. We have the ECG simulate duration, sampling rate, heart rate, zones of fourth. That's nice. We also need to do processing. Can we combine the current Python script with this one? So this is the code that we actually want to use. It can integrate processing from the private script into the Flask app. Then return the process data client-side for plotting. The client-side will be responsible for rendering the plot based on the process data sent to the server. Seem legit. That's good. Yeah, one of those variables as well. But we can do it later. We still haven't got anything working. And why do I have a feeling something is still missing process? That's right. Yeah, there's this big four. For every R peak to this removing duplicate. Don't think that's actually a problem, so maybe it's OK that it got rid of it. 27, 54. OK. This would not work. Right, we need to adjust the JavaScript success function. What? This is success function. Doesn't sound like a good name. This is success. What? What's that all about? Yeah, JavaScript. We have a new JavaScript. It used to be 34 lines. That's like 75. That makes more sense. So we're using both the JavaScript that we have, and then JavaScript from jQuery and JavaScript from Plotly. And I don't think the HTML changed much anyway. We had 32. Now we have 34. That's OK. Let's run the app again. Yes, do not use in production. OK, we're still not generating Y. There's something with the variables that is out of proportion or something. So I'm quite understand. What's this error all about? Because the length value is not an integer. OK, that should be a simple fix, shouldn't it? We're in our Python code. Right, the ceiling must be rounding it up towards the ceiling. Then generate ECG, duration float, integer, integer. Round up the duration to the nearest integer. OK, it's still weird. It would not work as it is. But typically, it occurs. The problem is serialized. So we need to serialize before we turn into JSON. Objects are right because it's turning it to list. We actually want to get rid of those magic numbers, turn them into variables. So you can select them on the input parameters. But for now, convert numpy right to list. And the rest of the code, data, ECG to list. Isn't that the same? Why am I converting twice? Maybe it's not the same. I can just can't see the difference. And the other thing we need to update this tells CSS because you're trying to buy unary negative operator to at least replace this line. Why are we invading stuff? Anyway, why are we buying negative peaks for Q&S? Why do we need to invert? Just find the negative peaks to understand why we need to do it. And then complete that path will be blah, blah, blah. Oh, come on. Tending to convert at least to a list again. Yeah, just remove to list in the line point to list, to list. Like this. Should have to list only once, I think. We have a two-wise segment ECG to list. And truly, ECG is also to list. We had it to begin with, so to list, to list, to list. Still getting an error. It's a long one. Trace back, trace back, back. See, because there's numpy, numpy in 64 type in your data, JSON doesn't know how to handle this data. Yeah, we had similar problems before. We need to convert the numpy integers to Python native integer type before passing them to JSON file. And data points, band point. Do we need to do all this point, point, point data points in JSON file data? Come on, give me something. OK, now it's working. Yeah, whatever, I tried to say, we had three. Why? Why is three too small? About four. Three shouldn't be too small. OK, keep it for whatever, four. This can be 250. We don't need 1,000 or whatever it was. OK, labeling is not great, is it? You don't convert float to integer, but it's not. There was a glitch there. Yeah, over there. Yeah, what's up with that? That's not great. Why there's so many of these labels in the caption? Can we have the plot displayed and labeled as soon as we load the page the first time? Also, can we have the chart ECG plot updated when the values, input values are changed by the user? I'm only finding the JavaScript and HTML. Is this the whole code and the whole date? Intervent listener, this can be the whole plot. JavaScript, 75 lines, script.js. This is not the whole code. Can possibly be 75 lines. This one looks like 20 or 30 or so. Let's save that in HTML. The form has changed. And just gave it the name, ID. It's already had an ID. Yeah, label ID. Anyway, we need this. It's for sure. Why is it not showing a chart? Chart is not showing. All right, because something is missing. It's not the whole code. Come on. Provide the JavaScript code is complete and should work when your guest will update. This is as soon as the web page loads and also whenever it's used on the bar. There are no errors in console, but the chart is not displaying anything anymore. There's nothing to troubleshoot. It was doing it a second ago. Nothing to troubleshoot. It was doing it with the previous JSON script. Come on, this is not it. Getting confused. Oh, come on. It's now getting all mixed up.