Replit db setting value error
If you see in the repl you will see in main.py on line 31 I used replitdb to store the username. but it shows :
Traceback (most recent call last): File "main.py", line 27, in <module> app.run(host='0.0.0.0', port=8080) File "/opt/virtualenvs/python3/lib/python3.8/site-packages/flask/app.py", line 922, in run run_simple(t.cast(str, host), port, self, **options) File "/opt/virtualenvs/python3/lib/python3.8/site-packages/werkzeug/serving.py", line 1008, in run_simple inner() File "/opt/virtualenvs/python3/lib/python3.8/site-packages/werkzeug/serving.py", line 948, in inner srv = make_server( File "main.py", line 31 db["user_id"] = user_id, # asking on replit.com/ask ^ SyntaxError: expression cannot contain assignment, perhaps you meant "=="?
and my code for that line (just that lines in which I think the error is)
user_id = request.headers['X-Replit-User-Id'], uid = generate_password_hash(user_id, "sha256"), db["user_id"] = uid,
\\\\\\\## THANKS IN ADVANCE ##////////////////
I didnt quite understand... does the flask to py work? Dont you need to do
@app.route("/whatwvevr",method=["POST","GET"])? And for line 31,
db['whatever'] = user sets the key whatever's value : user (your webpage doesnt wakeup for me.. sorry)
db["user_id"] 's value is a dictionary or just a string? If its a dictionary and
user_idkey is in the dict then it should work. If its a string/float/integer, then
user_name_hashed is a variable and you cannot run the
user_name_hashed["user_id"] as this is a dictionary command.
@Yoplayer1py uhmmm... i dont know what are yountryong to accomplish. Based on the code you commented a while back, i assume that this might work...
user_name_hashed = db["user_id"] uid = user_name_hashed``` Idk whether you want the uid to be set user_name_hashed or vice versa. Try this, if it didnt work, then idk how to fix
@QuantumCodes I am trying to hash a username which I get by replauth .
user_name_hashed is a var which creates the key user_id I want the valuse to be
uid which is the hash of the variable
user_id = request.headers['X-Replit-User-Id']
I make the hash using werkzeug:
Hope you understand it now.
Look through code here: https://replit.com/@QuantumCodes/Repl-Pinger#Keep.py
. I made that. It uses HTML to get data and also uses db to save. See whether you get ur answer there... @Yoplayer1py