Restrict access unless user is on a certain domain?
I’ve been asking a lot of questions recently. I’m getting ready to deploy my Django site soon. However, to ensure there’s further security. I only want it to be accessible to users on a certain domain. Meaning, once they are connected to a certain VPN domain. *.mydomain.com, access is allowed and user can log in. If they aren’t on that domain, they aren’t able to view or log in.
/r/djangolearning
https://redd.it/12r2gjt
I’ve been asking a lot of questions recently. I’m getting ready to deploy my Django site soon. However, to ensure there’s further security. I only want it to be accessible to users on a certain domain. Meaning, once they are connected to a certain VPN domain. *.mydomain.com, access is allowed and user can log in. If they aren’t on that domain, they aren’t able to view or log in.
/r/djangolearning
https://redd.it/12r2gjt
Reddit
r/djangolearning on Reddit: Restrict access unless user is on a certain domain?
Posted by u/HeadlineINeed - 2 votes and 7 comments
Out of curiosity: what is the python project structure you usually go gor?
/r/Python
https://redd.it/12qit60
/r/Python
https://redd.it/12qit60
Reddit
r/Python on Reddit: Out of curiosity: what is the python project structure you usually go gor?
Posted by u/MeGuaZy - 93 votes and 88 comments
Python's pathlib Module: Taming the File System – Real Python
https://realpython.com/python-pathlib/
/r/Python
https://redd.it/12qo5ji
https://realpython.com/python-pathlib/
/r/Python
https://redd.it/12qo5ji
Realpython
Python's pathlib Module: Taming the File System – Real Python
Python's pathlib module enables you to handle file and folder paths in a modern way. This built-in module provides intuitive semantics that work the same way on different operating systems. In this tutorial, you'll get to know pathlib and explore common tasks…
Wednesday Daily Thread: Beginner questions
New to Python and have questions? Use this thread to ask anything about Python, there are no bad questions!
This thread may be fairly low volume in replies, if you don't receive a response we recommend looking at r/LearnPython or joining the Python Discord server at https://discord.gg/python where you stand a better chance of receiving a response.
/r/Python
https://redd.it/12r9j0k
New to Python and have questions? Use this thread to ask anything about Python, there are no bad questions!
This thread may be fairly low volume in replies, if you don't receive a response we recommend looking at r/LearnPython or joining the Python Discord server at https://discord.gg/python where you stand a better chance of receiving a response.
/r/Python
https://redd.it/12r9j0k
Discord
Join the Python Discord Server!
We're a large community focused around the Python programming language. We believe that anyone can learn to code. | 412982 members
Websocket connection failed & Not Found: /ws/home/room
new to django-channels and websockets in python and have been struggling with a big project, I can't figure out why I keep getting the errors in the title I even created a new project and followed a youtube tutorial step by step and still get the error
\- the main difference between mine and his is that my user flow goes through three pages -> login to home to the room- I also didn't initialize a virtual environment for my django project (don't think that matters)
from inspection i get websocket connection not found 'ws:// {localhost}/ws/home/room' and from project console i get Not Found: /ws/home/roomI'm trying to learn as I go about websockets and everything but have been struggling with this issue for a while now (a couple days lol)
heres my code:
[urls.py](https://urls.py)
`urlpatterns = [path('', views.login, name='login'),path('home/', views.home, name='home'),path('home/<str:room_name>/', views.room, name='room'),]`
[routing.py](https://routing.py)
`websocket_urlpatterns = [re_path(r'^ws/home/(?P<room_name>\w+)/$', consumers.GameConsumer),]`
[consumers.py](https://consumers.py)
`class GameConsumer(AsyncWebsocketConsumer):def __init__(self, *args, **kwargs):super().__init__(args, kwargs)self.room_name = Noneself.room_group_name = Noneasync def connect(self):self.room_name = self.scope['url_route']['kwargs']['room_name']self.room_group_name = '_%s' % self.room_name # unsure about 'game_%s'''' create new group '''await self.channel_layer.group_add(self.room_group_name,self.channel_name,)`
`await self.accept()`
`await self.channel_layer.group_send(self.room_group_name,{'type': 'tester_message','tester': 'hello world',})`
`async def tester_message(self, event):tester = event['tester']`
`await self.send(text_data=json.dumps({'tester': tester}))`
`async def disconnect(self, close_code):await self.channel_layer.group_discard(self.room_group_name,self.channel_name,)`
and heres where i create the websocket connection
`{{ room_name|json_script:"room-name" }}<script>const roomName = JSON.parse(document.getElementById('room-name').textContent)const socket = new WebSocket('ws://' +window.location.host
/r/djangolearning
https://redd.it/12r4wnx
new to django-channels and websockets in python and have been struggling with a big project, I can't figure out why I keep getting the errors in the title I even created a new project and followed a youtube tutorial step by step and still get the error
\- the main difference between mine and his is that my user flow goes through three pages -> login to home to the room- I also didn't initialize a virtual environment for my django project (don't think that matters)
from inspection i get websocket connection not found 'ws:// {localhost}/ws/home/room' and from project console i get Not Found: /ws/home/roomI'm trying to learn as I go about websockets and everything but have been struggling with this issue for a while now (a couple days lol)
heres my code:
[urls.py](https://urls.py)
`urlpatterns = [path('', views.login, name='login'),path('home/', views.home, name='home'),path('home/<str:room_name>/', views.room, name='room'),]`
[routing.py](https://routing.py)
`websocket_urlpatterns = [re_path(r'^ws/home/(?P<room_name>\w+)/$', consumers.GameConsumer),]`
[consumers.py](https://consumers.py)
`class GameConsumer(AsyncWebsocketConsumer):def __init__(self, *args, **kwargs):super().__init__(args, kwargs)self.room_name = Noneself.room_group_name = Noneasync def connect(self):self.room_name = self.scope['url_route']['kwargs']['room_name']self.room_group_name = '_%s' % self.room_name # unsure about 'game_%s'''' create new group '''await self.channel_layer.group_add(self.room_group_name,self.channel_name,)`
`await self.accept()`
`await self.channel_layer.group_send(self.room_group_name,{'type': 'tester_message','tester': 'hello world',})`
`async def tester_message(self, event):tester = event['tester']`
`await self.send(text_data=json.dumps({'tester': tester}))`
`async def disconnect(self, close_code):await self.channel_layer.group_discard(self.room_group_name,self.channel_name,)`
and heres where i create the websocket connection
`{{ room_name|json_script:"room-name" }}<script>const roomName = JSON.parse(document.getElementById('room-name').textContent)const socket = new WebSocket('ws://' +window.location.host
/r/djangolearning
https://redd.it/12r4wnx
Astral, the company behind Ruff
https://astral.sh/blog/announcing-astral-the-company-behind-ruff
I am not Charlie Marsh, so this isn't my blog. But I found the premise and the news very interesting and exciting!
/r/Python
https://redd.it/12r7oi0
https://astral.sh/blog/announcing-astral-the-company-behind-ruff
I am not Charlie Marsh, so this isn't my blog. But I found the premise and the news very interesting and exciting!
ruff has become a can't-live-without tool very quickly, and I'm excited to see what comes out of Astral next/r/Python
https://redd.it/12r7oi0
astral.sh
Announcing Astral, the company behind Ruff
Astral’s mission is to make the Python ecosystem more productive by building high-performance developer tools, starting with Ruff.
Handling Security of Encrypted Data
I want to make an application that is related to crypto. The user would enter a password, that would decrypt a crypto wallet key that is stored in a SQL database, and allow them to use this wallet to run transactions.
I do not want them to enter it for every action, I want to store the decrypted wallet key/the password (ill refer to either as the key) somewhere so it is a smooth interaction. I am curious about the security ethics around this. Where would I store the key, in browser cookies on the client side? If so, how secure is this, and how secure is sending the key back and forth via POSTS to the backend server?
/r/flask
https://redd.it/12r96bd
I want to make an application that is related to crypto. The user would enter a password, that would decrypt a crypto wallet key that is stored in a SQL database, and allow them to use this wallet to run transactions.
I do not want them to enter it for every action, I want to store the decrypted wallet key/the password (ill refer to either as the key) somewhere so it is a smooth interaction. I am curious about the security ethics around this. Where would I store the key, in browser cookies on the client side? If so, how secure is this, and how secure is sending the key back and forth via POSTS to the backend server?
/r/flask
https://redd.it/12r96bd
Reddit
Handling Security of Encrypted Data : r/flask
80K subscribers in the flask community. Flask is a Python micro-framework for web development. Flask is easy to get started with and a great way to…
Dockerized Django with Postgres, Gunicorn, and Traefik (with Let's Encrypt)
Hey fellow Django enthusiasts!
I've created a cool project template that you can use as a foundation for your future projects by simply copying it: https://github.com/amerkurev/django-docker-template
The main idea is to solve all deployment-related issues at the initial stage. In this project, everything is built in Docker, launched with Docker Compose, and Let's Encrypt certificate is automatically issued (you just need to have a domain). The certificate is also automatically renewed. It is configured through environment variables and described how to work in development mode and how to deploy to production.
But the most important thing is the minimalism of this project. It has nothing extra, it's easy to extend or modify.
Personally, I now use it everywhere I need to quickly deploy a Django website. And it only takes me a couple of minutes to deploy everything in the cloud. Then I just write my Django applications.
​
I would be very happy if you want to support the project with a PR, an interesting idea, or find bugs and write about it in the issue. Or at least give the project a star :)
I really love Django and value the Django community because it's a really cool product and cool people!
/r/django
https://redd.it/12r59gh
Hey fellow Django enthusiasts!
I've created a cool project template that you can use as a foundation for your future projects by simply copying it: https://github.com/amerkurev/django-docker-template
The main idea is to solve all deployment-related issues at the initial stage. In this project, everything is built in Docker, launched with Docker Compose, and Let's Encrypt certificate is automatically issued (you just need to have a domain). The certificate is also automatically renewed. It is configured through environment variables and described how to work in development mode and how to deploy to production.
But the most important thing is the minimalism of this project. It has nothing extra, it's easy to extend or modify.
Personally, I now use it everywhere I need to quickly deploy a Django website. And it only takes me a couple of minutes to deploy everything in the cloud. Then I just write my Django applications.
​
I would be very happy if you want to support the project with a PR, an interesting idea, or find bugs and write about it in the issue. Or at least give the project a star :)
I really love Django and value the Django community because it's a really cool product and cool people!
/r/django
https://redd.it/12r59gh
GitHub
GitHub - amerkurev/django-docker-template: Dockerized Django with Postgres, Gunicorn, and Traefik or Caddy (with auto renew Let's…
Dockerized Django with Postgres, Gunicorn, and Traefik or Caddy (with auto renew Let's Encrypt) - amerkurev/django-docker-template
Sample flash app can't be accessed by other device in the local network with host="0.0.0.0" & turned off firewall
I created a simple flash app as followings ...
\---------------
from flask import Flask
app = Flask(__name__)
@ app.route("/")
def hello():
return "Hello World!"
if __name__ == "__main__":
app.run(host="0.0.0.0")
\---------------
Running the same flask app on both Windows machine#1 (M1) and Windows Machine#2 (M2). M2 can access to M1. No issue. However, the other way around didn't work.
\-- M2 is running flask app with host="0.0.0.0." and turned off firewall from McAfee
\-- M1 can't access the M2 flask app by ip address (192.168.0.111)
\>>> http://192.168.0.111:5000
Any ideas how to troubleshoot this?
/r/flask
https://redd.it/12r6eao
I created a simple flash app as followings ...
\---------------
from flask import Flask
app = Flask(__name__)
@ app.route("/")
def hello():
return "Hello World!"
if __name__ == "__main__":
app.run(host="0.0.0.0")
\---------------
Running the same flask app on both Windows machine#1 (M1) and Windows Machine#2 (M2). M2 can access to M1. No issue. However, the other way around didn't work.
\-- M2 is running flask app with host="0.0.0.0." and turned off firewall from McAfee
\-- M1 can't access the M2 flask app by ip address (192.168.0.111)
\>>> http://192.168.0.111:5000
Any ideas how to troubleshoot this?
/r/flask
https://redd.it/12r6eao
Reddit
r/flask on Reddit: Sample flash app can't be accessed by other device in the local network with host="0.0.0.0" & turned off firewall
Posted by u/rockies_user - 1 vote and 3 comments
Chili - serialize/deserialize anything from/to dict/json
Hi Python enthusiasts!
I'm thrilled to announce the launch of Chili 2.0, a major update to my object serialization and deserialization library with JSON support. After 2 years of development, I'm excited to share this new version with the Python community.
Chili is a Python library that makes it easy to serialize and deserialize any Python object to and from dict and/or JSON.
I encourage you to check out the GitHub repository to learn more about what's new in Chili 2.0. You'll find detailed documentation, examples, and installation instructions under the following link:
http://github.com/kodemore/chili
How it is different than pydantic? Chili is not a validation library, although it ensures type consistency. This gives it a huge perfomance advantage + easy interface with zero learning curve if you are already familiar with type annotations available in python.
And if you have any questions or feedback, please don't hesitate to reach out. I'd love to hear from you!
/r/Python
https://redd.it/12rkgoc
Hi Python enthusiasts!
I'm thrilled to announce the launch of Chili 2.0, a major update to my object serialization and deserialization library with JSON support. After 2 years of development, I'm excited to share this new version with the Python community.
Chili is a Python library that makes it easy to serialize and deserialize any Python object to and from dict and/or JSON.
I encourage you to check out the GitHub repository to learn more about what's new in Chili 2.0. You'll find detailed documentation, examples, and installation instructions under the following link:
http://github.com/kodemore/chili
How it is different than pydantic? Chili is not a validation library, although it ensures type consistency. This gives it a huge perfomance advantage + easy interface with zero learning curve if you are already familiar with type annotations available in python.
And if you have any questions or feedback, please don't hesitate to reach out. I'd love to hear from you!
/r/Python
https://redd.it/12rkgoc
GitHub
GitHub - kodemore/chili: Object serialization/deserialization tools for python.
Object serialization/deserialization tools for python. - kodemore/chili
Best way to organize Django Channels code?
In Django, I usually create a file called a "services" file. The entire business logic sits in this services file. Whenever a request comes the flow will be "urls.py -> views.py -> services.py". My views.py just calls the services.py file and it also handles the exceptions that I throw from the service function.
I've been exploring Django Channels for the last few days and I'm trying to build a chat app. Here I have a consumers.py file and I put the entire chat logic in the class "ChatConsumer". I don't know if this is the best approach. Most of the Django Channels tutorials and examples are just putting the entire logic in one class. What's the best way to organize the code?
I'm thinking of using a services file here as well and then move the entire logic to the services file. Not sure if this is the best approach. Please suggest a good way to organize the Django Channels code.
/r/django
https://redd.it/12ri12u
In Django, I usually create a file called a "services" file. The entire business logic sits in this services file. Whenever a request comes the flow will be "urls.py -> views.py -> services.py". My views.py just calls the services.py file and it also handles the exceptions that I throw from the service function.
I've been exploring Django Channels for the last few days and I'm trying to build a chat app. Here I have a consumers.py file and I put the entire chat logic in the class "ChatConsumer". I don't know if this is the best approach. Most of the Django Channels tutorials and examples are just putting the entire logic in one class. What's the best way to organize the code?
I'm thinking of using a services file here as well and then move the entire logic to the services file. Not sure if this is the best approach. Please suggest a good way to organize the Django Channels code.
/r/django
https://redd.it/12ri12u
Reddit
r/django on Reddit: Best way to organize Django Channels code?
Posted by u/God-of-war-2022 - 6 votes and 2 comments
Web Scraping With Python(2023) - A Complete Guide
https://serpdog.io/blog/web-scraping-with-python/
/r/Python
https://redd.it/12s6bt8
https://serpdog.io/blog/web-scraping-with-python/
/r/Python
https://redd.it/12s6bt8
scrapingdog
Comprehensive Guide on Web Scraping with Python
This guide is a full guide for someone who want to learn web scraping with Python. We have used 8 libraries to demonstrate scraping with live examples.
Jupyter Notebooks 7 Migration Plan
Hi Jupyter family, I would like to migrate over to Jupyter Notebook v7 as detailed in their migration plan (https://jupyter-notebook.readthedocs.io/en/latest/migrate\_to\_notebook7.html). Not going to lie, I have a degree in CS and I still do not understand what I need to do in-order to get jupyter-notebook 7 up and running in my 'data-science' env. The guide is both verbose and overly complicated (opinion) for simple folk like me. Can someone please ELI5 how to install it and get it up and running please?
/r/JupyterNotebooks
https://redd.it/12s3von
Hi Jupyter family, I would like to migrate over to Jupyter Notebook v7 as detailed in their migration plan (https://jupyter-notebook.readthedocs.io/en/latest/migrate\_to\_notebook7.html). Not going to lie, I have a degree in CS and I still do not understand what I need to do in-order to get jupyter-notebook 7 up and running in my 'data-science' env. The guide is both verbose and overly complicated (opinion) for simple folk like me. Can someone please ELI5 how to install it and get it up and running please?
/r/JupyterNotebooks
https://redd.it/12s3von
Reddit
r/JupyterNotebooks on Reddit: Jupyter Notebooks 7 Migration Plan
Posted by u/Chayalbodedd - 1 vote and 1 comment
In DRF do you validate your query params, if so how?
I know "how?" part bit generic question but let's say you have an student & school API and depending on the uuid you are doing some filtering which directly goes to ORM and if the query param is not valid UUID API will give 500.
However, I also don't recognize query params being validated much, especially like serializers.
I have to validate it but I also don't know what would be the best practices to achieve this?
/r/django
https://redd.it/12rspek
I know "how?" part bit generic question but let's say you have an student & school API and depending on the uuid you are doing some filtering which directly goes to ORM and if the query param is not valid UUID API will give 500.
However, I also don't recognize query params being validated much, especially like serializers.
I have to validate it but I also don't know what would be the best practices to achieve this?
/r/django
https://redd.it/12rspek
Reddit
r/django on Reddit: In DRF do you validate your query params, if so how?
Posted by u/Mr_Lkn - 11 votes and 23 comments
Thursday Daily Thread: Python Careers, Courses, and Furthering Education!
Discussion of using Python in a professional environment, getting jobs in Python as well as ask questions about courses to further your python education!
This thread is not for recruitment, please see r/PythonJobs or the thread in the sidebar for that.
/r/Python
https://redd.it/12sf4mb
Discussion of using Python in a professional environment, getting jobs in Python as well as ask questions about courses to further your python education!
This thread is not for recruitment, please see r/PythonJobs or the thread in the sidebar for that.
/r/Python
https://redd.it/12sf4mb
Reddit
r/Python on Reddit: Thursday Daily Thread: Python Careers, Courses, and Furthering Education!
Posted by u/Im__Joseph - No votes and no comments
editair webapp
Hey! I was playing around with flask for a backend API and built a webapp that converts long form videos into short form sharable content. I linked the demo below. If this is something that could be useful to you or someone you know, sign up for the beta and let me know via DM or tyler@editair.app
editair webapp
demo video
If it is a project you think you could help on the dev side, also let me know!
/r/flask
https://redd.it/12sdzzy
Hey! I was playing around with flask for a backend API and built a webapp that converts long form videos into short form sharable content. I linked the demo below. If this is something that could be useful to you or someone you know, sign up for the beta and let me know via DM or tyler@editair.app
editair webapp
demo video
If it is a project you think you could help on the dev side, also let me know!
/r/flask
https://redd.it/12sdzzy
www.editair.app
EditAir: AI-Driven Video Editing
Effortless AI content creation. Generate repurposed, shareable short-form clips from podcasts, gameplay, and other videos in minutes.
Visual Programming with Jupyterlite?
I found these guys that create code from graphic representation and like the idea, do you like the idea of generating code from visuals?
https://www.tiktok.com/@cubode/video/7223369296288812293
/r/IPython
https://redd.it/12s1zel
I found these guys that create code from graphic representation and like the idea, do you like the idea of generating code from visuals?
https://www.tiktok.com/@cubode/video/7223369296288812293
/r/IPython
https://redd.it/12s1zel
TikTok
cubode - learn to code fast 🚀 on TikTok
We asked our CTO David to create a tiktok explaining a feature of platform. He normally does the coding and didn’t want us to publish it, because he says this wasnt in his job description. But we are a startup and sometimes a founder has to wear many hats…
Software engineering with Python?
I have been self-studying python for a little bit over a month. I don't exactly wanna go into data analyst/data science/ data engineering, etc. my goal is to become a software engineer/developer (maybe something to do with backend). did I choose the wrong language?
EDIT: @ evryone fucking love you guys. I was so damn confused this morning when i posted this, the 52 comments cleared up so many things you have no idea. I haven't even finished digesting all the information but that clears up so much!!
/r/Python
https://redd.it/12rsedi
I have been self-studying python for a little bit over a month. I don't exactly wanna go into data analyst/data science/ data engineering, etc. my goal is to become a software engineer/developer (maybe something to do with backend). did I choose the wrong language?
EDIT: @ evryone fucking love you guys. I was so damn confused this morning when i posted this, the 52 comments cleared up so many things you have no idea. I haven't even finished digesting all the information but that clears up so much!!
/r/Python
https://redd.it/12rsedi
Reddit
r/Python on Reddit: Software engineering with Python?
Posted by u/bentleySauvignon - 57 votes and 75 comments