Python Daily
2.57K subscribers
1.48K photos
53 videos
2 files
38.9K links
Daily Python News
Question, Tips and Tricks, Best Practices on Python Programming Language
Find more reddit channels over at @r_channels
Download Telegram
Kangas V2: Explore multimedia data

Project: [https://github.com/comet-ml/kangas](https://github.com/comet-ml/kangas)

Demo: [https://kangas.comet.com/](https://kangas.comet.com/)

​

We've just released version 2 of Kangas, our open source platform for exploring large, multimedia datasets. At a high-level, Kangas provides:

* A Python interface for constructing large tables of multimedia data (DataGrids), which should be very familiar to any Pandas users.
* A backend built on SQLLite and Flask for storing/querying/serving DataGrids.
* A UI built on React Server Components with Next 13 that enables fast, interactive exploration of your data

https://i.redd.it/ldpbbkb70nua1.gif

Kangas provides out of the box support for complex querying operations, as well as a variety of computer vision functionality (bounding boxes, labels, annotations, etc.) Additionally, the UI is customizable—you can resize, filter, and reorder columns as you like.

You can run Kangas from within a notebook, as a local app via the Kangas CLI, or even deploy it as a standalone web application (as we've done at [https://kangas.comet.com](https://kangas.comet.com))

Finally, I want to include a thank you here. About 5 months ago, I shared Kangas' initial V1 release here in r/Python, and several of you made your way over to the repo to share feedback and support. This was massively helpful for us. It helped us figure out what to prioritize, and opened our eyes to new features we hadn't considered.

/r/Python
https://redd.it/12qlmup
Using React with Django

My Django app is now becoming bigger, and the front end part (in vanilla JS) becomes pretty unmaintainable. I would like to change the front end to React, since it is component based and so it is more organized. It also has a dedicated testing framework for front-end use (unlike vanilla JS), and so I can ensure my front-end logic is robust. Does anyone ever done migration from Vanilla JS to React? How would the Django template work there? Does it work the same, and if so was it hard to write tests for them?

/r/django
https://redd.it/12qqxrv
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
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
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
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!

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
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
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.

&#x200B;

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
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
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
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
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
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
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
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