135201
You will be muted until you read the rules. Read them! @Rules_for_Python A group about the Python programming language. Offtopic things go here: @pythonofftopic Resources to learn python: @pythonres Group for Hy: @hylang Selenium: @SeleniumPython
How can I learn Python quickly? I feel like it’s really difficult and confusing, and there are so many things to learn.
Читать полностью…
Is it necessary to create a venv even if the project is finished and was working fine?
Читать полностью…
Comparatively perhaps. But doesn't mean you'll become a good developer over night. It's effort nonetheless. I'd rather say Python is pretty and versatile.
Читать полностью…
I understand the desire to get things done, but this particular group is about learning Python. Not commanding LLMs.
Читать полностью…
but but i am found one issue whatever i am taking values form the .env of my python and send it on the @context_processor, but actually the user can inspect and visist the secure private data i send to there using html to js. so no security there he can visit this values i pass over this
I have a question about passing data from Python to HTML hidden fields. When inserting values from Python into my HTML hidden fields, I sometimes need to pass the correct data type. For example, if I have a variable like money = float, I need to send it, but HTML stores it as a string, so JavaScript will try to convert it into an int and use it.
Additionally, consider this regular expression:var UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
In this case, how should I take it from Python's backend and pass it into JavaScript, given that this is not a simple string type in JS? Also, if I want to pass this via a Python context_processor, what should the data type be in Pydantic's pydantic-settings?
You pass it to HTML document and grab its value with JS 🤷♂
Читать полностью…
Please refrain from sharing content nobody has asked for.
Читать полностью…
Any that you have available, when knowing nothing any material is an option
Читать полностью…
👋 I agree with clouded. You must effort in code. I can help you develop your own project.
Читать полностью…
i was looking into Flask and Flask-WTF today and noticed a recommendation to use CSRF tokens as much as possible. as I understand that even if a page doesn't have a form, we should still check for CSRF on PUT, PATCH, or UPDATE requests, thats' why the token is often placed in the meta head tag.
My question is: when JavaScript fetches data and sends requests automatically, should I attach the CSRF token to these requests?
I read that for automatic JS operations, we can use @csrf.exempt and avoid passing the token. What do you guys think? and i also listen i should never use exept for db query, what do you guys would choose in this case for automatic js request from the browser to server should we impliment csrf token in flask-wtf?
You do not put secrets in frontend
That is a simple rule at least
Depending on how much JS you need to inject, you could consider using .format() on a js as a string and replace the values that way 🤷♂
So you skip all the python > html > js dance
https://docs.python.org/3/builtins/stdtypes.html#str.format
yaa thats looks logical now, i will do serachElementBYID in my js code from a hidden <span> and from there the js will take the value 😅
Читать полностью…
Hello, I was using Flask to build HTML with Jinja and send it to the user's browser like this: 🐍return render_template("index.html", user=user_data, money=users_db.money_value,)
for this case, user and money values are inserted into the Flask template on the fly coming from Python3.
However, when I try to send the/static/js/filename.js
file, it is served automatically. As a result, I have to hardcode each variable in the .js file, since Flask automatically sends the .js file to the user without dynamic context. 😢
var UUID_RE =-Za-z0-9_-]+)/;
var SHORT_RE = ([A-Za-z0-9_-]+)/i;
var HOOK_RE = -9a-f]{4}-[0-9a-f]{12})/i;
var DEFAULT_PROXY = "/api/endpoint/somethign?url=";
var HOOK_API = "/video/web/somethign";
That's not helpful. And a reason for a warning from different perspectives.
Читать полностью…
defined a simple function, def, a list, and a dictionary — in every case it printed the value correctly, because Python's print() works on any object type by converting it to its string representation internally, so the function doesn't care what kind of data x holds 🐍. However, when I called show() with no arguments at all, Python raised a TypeError: show() missing 1 required positional argument: 'x', and when I called it with two arguments like show("hello", "world"), it raised TypeError: show() takes 1 positional argument but 2 were given — this happens because while Python is flexible about the type of data a function accepts, it strictly enforces the number of arguments based on the function's signature, and since x has no default value, exactly one argument must be supplied, no more and no less; if you wanted to allow a flexible number of arguments, you'd need to use a default value like def show(x=None): or a variadic form like def show(*args): instead 🛠️.
Читать полностью…