Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 7503

Other programming languages • Round Data for Web Page - Flask/HTML

$
0
0
I'm building a web page and server for a TOF sensor What is a simple way to format the data so it shows up as 1 decimal place on the web page?

I tied in Python

Code:

    templateData = {          'title' : " My VL6180X TOF",          'range_mm' : range_mm          #'range_mm' : range_mm.toFixed(1) does not work    }
I tried in the HTML index file

Code:

   <body>      <h1>Welcome to my VL6180X/Flask App!</h1>      <p>This message comes from an HTML template.</p>      <p>The Range: {{ range_mm | round(1) }}mm</p>            <div class="image-container">         <img src="static/Level01.jpg">         <div class="overlay-text">The Range: {{ range_mm }}mm</div>      </div>    </body>
neither work, I'm brain locked right now!

Statistics: Posted by OldPCGuy — Sun Feb 22, 2026 8:33 pm — Replies 2 — Views 43



Viewing all articles
Browse latest Browse all 7503

Trending Articles