-1

Python code:

from flask import Flask, render_template
app = Flask(__name__)

@app.route("/")
def test():
    id = "2138291837273817238" # Can Be some random number
    return render_template("first.html", id=id)

if __name__ == "__main__":
    app.run("0.0.0.0", 8000)

Html:

<!DOCTYPE html>
<html>
<title>Testing</title>
<body style="background-color:#222736;">
<h1 style="color:#f6f6f6">Testing</h1>
</body>

<script>
console.log({{ id }})
</script>
</html>

Javascript console:

2138291837273817300

As you can see, 2138291837273817238 and 2138291837273817300 are not the same number. The parameter is always rounded up at the 17th number. Is this just a JavaScript error? Am I doing something wrong? And can someone reproduce this?

khelwood
  • 55,782
  • 14
  • 81
  • 108
cfvWEW
  • 21
  • 1
  • 2

1 Answers1

0

Solved: I had to put {{ id }} into "´s, so its "{{ id }}", then it isnt rounded up!

cfvWEW
  • 21
  • 1
  • 2
  • Then it is no longer a number. You "number" is larger than the largest JS can handle safely without BigInt (Number.MAX_SAFE_INTEGER: 9007199254740991) – mplungjan Jan 23 '22 at 12:21