javascript

how to stop the countdown loop

how to stop the countdown loop Question: I am trying to create a countdown, how when it goes to 0 it will stop the loop and show a message import time countdown = 100 while True: display = " [ Countdown {:03d} ] ".format(countdown) print(display, end="r") time.sleep(2) countdown -= 1 Asked By: MThien || Source …

Total answers: 3

is it possible to access JavaScript variables in Jinja?

is it possible to access JavaScript variables in Jinja? Question: How can I access javascript variables in the jinja template? Example: <script> let data_str = "video1"; let url = `{% url "renderVideo" args="${data_str}" %}` </script url: path("videoplay/<str:args>", views.videoplay, name="videoplay") Traceback: Internal Server Error: /videoplay/${data_str} I’m expecting /videoplay/video1 but it is not parsing the JavaScript variable. …

Total answers: 1

Trying to pass a nested list with JSON to JS with Flask

Trying to pass a nested list with JSON to JS with Flask Question: The problem is I’m passing my argument to the Javascript like this: link. The variable "chatlist" is the problem. The value of that variable is [[{"user": "lol"}, {"msg": "lol has created this chat."}], [{"user": "lol"}, {"msg": "lol"}]] But when I try to …

Total answers: 2

Need Equivalent Python Script from JS

Need Equivalent of SHA1 function in python Question: Please help me convert below JS code to Python. const di_digest = CryptoJS.SHA1(di_plainTextDigest).toString(CryptoJS.enc.Base64); di_plainTextDigest is a String. I tried a few Python methods, but not working. Example result = hashlib.sha1(di_plainTextDigest.encode()) hexd = result.hexdigest() hexd_ascii = hexd.encode("ascii") dig2 = base64.b64encode(hexd_ascii) dig3 = dig2.decode("ascii") print(dig3 ) Asked By: Prudhvi …

Total answers: 1

Chrome Extension Requesting django server

Chrome Extension Requesting django server Question: I am creating a chrome extension that requires a back end server for processing. I would like it to send data to the server, the server will process this data and send some other data back to the user. Preferably this back end server should be in python as …

Total answers: 1

How to decode a base64 encoded string returned from an api correctly

How to decode a base64 encoded string returned from an api correctly Question: Having a base64 string encoded JSON like object coming from a python API, what is the correct way to decode and parse the encoded JSON in javascript? Python makes it a byte string literal by adding b prefix and additional apostrophes. I …

Total answers: 1

Pycryptodome incorrect decryption

Pycryptodome incorrect decryption Question: I am generating a RSA key pair in a django view, storing the keys in db, sending the public key to the client template, encrypting a message, then sending the message to a different view where I am retrieving the private key from the db and trying to decrypt the message. …

Total answers: 1

Jquery Validation remote method always shows invalid

Jquery Validation remote method always shows invalid Question: I am trying to validate an html function with django and the JavaScript FormValidation plugin. I want validation to check if the inserted email already exists, This is my validation remote email: { validators: { notEmpty: { message: ’email field can not be empty’ }, emailAddress: { …

Total answers: 1

Fetch Request in Jinjia Include getting CORS Error

Fetch Request in Jinjia Include getting CORS Error Question: So I have a site that is using Flask for the Front and Backend with Jinja templates. Currently testing with localhost (5000 is the backend and 8000 is for the frontend) the page in question main.html <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> </head> <body> …

Total answers: 2