Django SaaS boilerplate with cookiecutter
https://github.com/ErnestoFGonzalez/djangorocket
/r/django
https://redd.it/10dhsg5
https://github.com/ErnestoFGonzalez/djangorocket
/r/django
https://redd.it/10dhsg5
GitHub
GitHub - ernestofgonzalez/djangorocket: A Django SaaS boilerplate
A Django SaaS boilerplate. Contribute to ernestofgonzalez/djangorocket development by creating an account on GitHub.
How to save files locally when AWS s3 is unavailable
Hi there! In our project we use s3 (via django-storages) as a default media storage, our application makes a lot of photos and sends it to the cloud. But in reality, our customers sometimes use our service with very unstable internet connection, so sometimes we cannot save images and just lose it.
I was thininking about overriding _save method of "S3Boto3Storage" adding condition checking if there is connection to AWS. And if no, save it using the new class instance of
And additionally I planned to schedule a celery job to try sending locally stored photos to S3 and delete it from the locale storage in case of success.
But seems like it is connecting to the AWS long time before _save method has been called, and that means that we need to override almost every method or to write own custom storage backend completely. Moreover, I am not really sure whether this will be a good practice. Does anyone have any suggestions or a piece of advice?
/r/django
https://redd.it/10dqxge
Hi there! In our project we use s3 (via django-storages) as a default media storage, our application makes a lot of photos and sends it to the cloud. But in reality, our customers sometimes use our service with very unstable internet connection, so sometimes we cannot save images and just lose it.
I was thininking about overriding _save method of "S3Boto3Storage" adding condition checking if there is connection to AWS. And if no, save it using the new class instance of
Django.core.files.storage.FileSystemStorageAnd additionally I planned to schedule a celery job to try sending locally stored photos to S3 and delete it from the locale storage in case of success.
But seems like it is connecting to the AWS long time before _save method has been called, and that means that we need to override almost every method or to write own custom storage backend completely. Moreover, I am not really sure whether this will be a good practice. Does anyone have any suggestions or a piece of advice?
/r/django
https://redd.it/10dqxge
reddit
How to save files locally when AWS s3 is unavailable
Hi there! In our project we use s3 (via django-storages) as a default media storage, our application makes a lot of photos and sends it to the...
Tuesday Daily Thread: Advanced questions
Have some burning questions on advanced Python topics? Use this thread to ask more advanced questions related to Python.
If your question is a beginner question we hold a beginner Daily Thread tomorrow (Wednesday) where you can ask any question! We may remove questions here and ask you to resubmit tomorrow.
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/10dwvx5
Have some burning questions on advanced Python topics? Use this thread to ask more advanced questions related to Python.
If your question is a beginner question we hold a beginner Daily Thread tomorrow (Wednesday) where you can ask any question! We may remove questions here and ask you to resubmit tomorrow.
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/10dwvx5
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
SocketIO but multiple "background threads" - where to "spawn" them?
Hi all! First time using the SocketIO package, and have read a ton of tutorials, but they're all kinda "bare minimum", and usually only use a single background thread, and on top of it, it's a "global" (eww).
I basically have a bunch of client-side ajax requests that I'm wanting to convert over to a SocketIO-type configuration where each ajax request is a separate thread that runs queries and returns data back to the clients.
I don't really know how to set this type of thing up where multiple background threads are working. Like, where to put it in my code exactly. I'm also not sure how to "monitor" those threads to know when one dies (for whatever reason) and needs to be re-spawned again.
Does anyone have a working example of this? I'm trying to avoid globals as well if possible.
/r/flask
https://redd.it/10e0kct
Hi all! First time using the SocketIO package, and have read a ton of tutorials, but they're all kinda "bare minimum", and usually only use a single background thread, and on top of it, it's a "global" (eww).
I basically have a bunch of client-side ajax requests that I'm wanting to convert over to a SocketIO-type configuration where each ajax request is a separate thread that runs queries and returns data back to the clients.
I don't really know how to set this type of thing up where multiple background threads are working. Like, where to put it in my code exactly. I'm also not sure how to "monitor" those threads to know when one dies (for whatever reason) and needs to be re-spawned again.
Does anyone have a working example of this? I'm trying to avoid globals as well if possible.
/r/flask
https://redd.it/10e0kct
reddit
SocketIO but multiple "background threads" - where to "spawn" them?
Hi all! First time using the SocketIO package, and have read a ton of tutorials, but they're all kinda "bare minimum", and usually only use a...
Comprehensive Guide to Testing a Flask Application with Pytest
Hey there guys!
I'm searching for some comprehensive guide on how to test a flask app. I have some protected views implemented with flask-login and can't test them easily. Also there's other functionality that's beyond the easy beginner stuff but my skill's not there yet. Do you know of some good resources to dive deeper into testing with a flask app?
/r/flask
https://redd.it/10ddd42
Hey there guys!
I'm searching for some comprehensive guide on how to test a flask app. I have some protected views implemented with flask-login and can't test them easily. Also there's other functionality that's beyond the easy beginner stuff but my skill's not there yet. Do you know of some good resources to dive deeper into testing with a flask app?
/r/flask
https://redd.it/10ddd42
reddit
Comprehensive Guide to Testing a Flask Application with Pytest
Hey there guys! I'm searching for some comprehensive guide on how to test a flask app. I have some protected views implemented with flask-login...
Trying to build a dynamic Table using Flask/turbo/threading
Hey guys
Im currently trying to create a dynamicly updating table, housing some data and I'm slowly loosing it.
The problem is, no matter what I do, I can't seem to get it to consistently update.
The wierd thing is, sometimes it will randomly work,but it will start duplicating the "delete all" button with every update. And then after a quick reload of the side, without changing anything in the code, it won't update anymore.
I also sometimes get a "GET /turbo-stream HTTP/1.1" 500 -" error, and then without changing anything, just restarting frontend.py, it won't appear again.
The following code is what I have currently:
frontend.py:
import threading
import time
from flask import Flask, Response, render_template, url_for
from turbo_flask import Turbo
from Backend import Backend
app = Flask(__name__)
turbo = Turbo(app)
app.config['SERVER_NAME'] = '192.168.2.183:5000'
#This is what trap_data looks like (for a single entry):
#(141, '192.168.1.1', 'Authentication Failure', 'Invalid username or password', 3, 1,
/r/flask
https://redd.it/10dw2xv
Hey guys
Im currently trying to create a dynamicly updating table, housing some data and I'm slowly loosing it.
The problem is, no matter what I do, I can't seem to get it to consistently update.
The wierd thing is, sometimes it will randomly work,but it will start duplicating the "delete all" button with every update. And then after a quick reload of the side, without changing anything in the code, it won't update anymore.
I also sometimes get a "GET /turbo-stream HTTP/1.1" 500 -" error, and then without changing anything, just restarting frontend.py, it won't appear again.
The following code is what I have currently:
frontend.py:
import threading
import time
from flask import Flask, Response, render_template, url_for
from turbo_flask import Turbo
from Backend import Backend
app = Flask(__name__)
turbo = Turbo(app)
app.config['SERVER_NAME'] = '192.168.2.183:5000'
#This is what trap_data looks like (for a single entry):
#(141, '192.168.1.1', 'Authentication Failure', 'Invalid username or password', 3, 1,
/r/flask
https://redd.it/10dw2xv
reddit
Trying to build a dynamic Table using Flask/turbo/threading
Hey guys Im currently trying to create a dynamicly updating table, housing some data and I'm slowly loosing it. The problem is, no matter what...
I can't get it to render a template, it just appears in the response and not on the webpage itself
https://redd.it/10dntuu
@pythondaily
https://redd.it/10dntuu
@pythondaily
reddit
I can't get it to render a template, it just appears in the...
Posted in r/flask by u/olishott • 5 points and 9 comments
Am I forced to put favicon.ico in the static directory?
I know that it is recommended to put it in the static directory and then add a link tag for it,
but I am just using flask as an easy way to handle the http stuff since I want to do stuff manually for now to ingrain how everything actually works, so rather than having a static directory I add an @app.route for each route/file request.
This seems to work fine for the css, html, and JavaScript files and everything else, but for some reason, despite my browser sending a get request for the favicon using the correct route, flask does not handle that route.
In the flask app I have:
@app.route(“/Images/favicon.ico”)
def getFavicon():
return send_file(“Images/favicon.ico”, mimetype=“image/x-icon”)
In the html head element I have:
<link href=“Images/favicon.ico” rel=“icon” type=“image/x-icon” />
Also on the JavaScript console I see a 404 for the request, but the request does not even show up in the flask app output on the terminal.
Does flask act weird because it’s an icon or something?
/r/flask
https://redd.it/10dwkbo
I know that it is recommended to put it in the static directory and then add a link tag for it,
but I am just using flask as an easy way to handle the http stuff since I want to do stuff manually for now to ingrain how everything actually works, so rather than having a static directory I add an @app.route for each route/file request.
This seems to work fine for the css, html, and JavaScript files and everything else, but for some reason, despite my browser sending a get request for the favicon using the correct route, flask does not handle that route.
In the flask app I have:
@app.route(“/Images/favicon.ico”)
def getFavicon():
return send_file(“Images/favicon.ico”, mimetype=“image/x-icon”)
In the html head element I have:
<link href=“Images/favicon.ico” rel=“icon” type=“image/x-icon” />
Also on the JavaScript console I see a 404 for the request, but the request does not even show up in the flask app output on the terminal.
Does flask act weird because it’s an icon or something?
/r/flask
https://redd.it/10dwkbo
reddit
Am I forced to put favicon.ico in the static directory?
I know that it is recommended to put it in the static directory and then add a link tag for it, but I am just using flask as an easy way to...
Each event should have be able to have mutliple, People and Organisations.
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///project.db'
db = SQLAlchemy(app)
class Event(db.Model):
__tablename__ = 'Event'
#id = db.Column(db.Integer, primary_key=True)
person_id = db.Column(db.Integer, db.ForeignKey('Person.id'), primary_key=True)
organisation_id = db.Column(db.Integer, db.ForeignKey('Organisation.id'), primary_key=True)
people = db.relationship('Person', uselist=True, back_populates="events")
organisations = db.relationship('Organisation', uselist=True, back_populates="events")
title = db.Column(db.String(255))
body = db.Column(db.String(255))
class Person(db.Model):
__tablename__ = 'Person'
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(255))
password = db.Column(db.String(255))
/r/flask
https://redd.it/10dskrd
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///project.db'
db = SQLAlchemy(app)
class Event(db.Model):
__tablename__ = 'Event'
#id = db.Column(db.Integer, primary_key=True)
person_id = db.Column(db.Integer, db.ForeignKey('Person.id'), primary_key=True)
organisation_id = db.Column(db.Integer, db.ForeignKey('Organisation.id'), primary_key=True)
people = db.relationship('Person', uselist=True, back_populates="events")
organisations = db.relationship('Organisation', uselist=True, back_populates="events")
title = db.Column(db.String(255))
body = db.Column(db.String(255))
class Person(db.Model):
__tablename__ = 'Person'
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(255))
password = db.Column(db.String(255))
/r/flask
https://redd.it/10dskrd
reddit
Each event should have be able to have mutliple, People and...
from flask import Flask from flask_sqlalchemy import SQLAlchemy app = Flask(__name__) app.config['SQLALCHEMY_DATABASE_URI'] =...
Read only object to share between sessions and requests
I have a look-up table which will be used in a read-only mode and should be created once when the flask server starts and maybe can be shared across the different requests to the server.
I am new to flask and web development and would you like to know the best way to achieve this in flask? The table is rather large (6 MBish) in size, so interested in minimizing memory overhead.
/r/flask
https://redd.it/10ddwm2
I have a look-up table which will be used in a read-only mode and should be created once when the flask server starts and maybe can be shared across the different requests to the server.
I am new to flask and web development and would you like to know the best way to achieve this in flask? The table is rather large (6 MBish) in size, so interested in minimizing memory overhead.
/r/flask
https://redd.it/10ddwm2
reddit
Read only object to share between sessions and requests
I have a look-up table which will be used in a read-only mode and should be created once when the flask server starts and maybe can be shared...
Mutable tuple views - einspect
Just finished adding all MutableSequence protocols for TupleViews. So pretty much all methods you can use on a list, you can now use on a tuple 👀
https://preview.redd.it/n14ywwpolkca1.png?width=1000&format=png&auto=webp&v=enabled&s=98373e593e60f58678265494f7ca9bc6739ea0b7
Feedback, issues, and PRs are welcome!
https://github.com/ionite34/einspect/
pip install einspect
A check also ensures resizes aren't outside of allocated memory. This means there is a limit to how much you can extend a tuple beyond its initial size.
from einspect import view
tup = (1, 2)
v = view(tup)
v: = 1, 2, 3, 4, 5
>> UnsafeError: setting slice required tuple to be resized beyond current memory allocation. Enter an unsafe context to allow this.
This is overrideable with an unsafe() context.
from einspect import view
tup = (1, 2)
v = view(tup)
with v.unsafe():
v: = 1, 2, 3, 4, 5
print(tup)
>> (1, 2, 3, 4, 5)
>>
/r/Python
https://redd.it/10e80md
Just finished adding all MutableSequence protocols for TupleViews. So pretty much all methods you can use on a list, you can now use on a tuple 👀
https://preview.redd.it/n14ywwpolkca1.png?width=1000&format=png&auto=webp&v=enabled&s=98373e593e60f58678265494f7ca9bc6739ea0b7
Feedback, issues, and PRs are welcome!
https://github.com/ionite34/einspect/
pip install einspect
A check also ensures resizes aren't outside of allocated memory. This means there is a limit to how much you can extend a tuple beyond its initial size.
from einspect import view
tup = (1, 2)
v = view(tup)
v: = 1, 2, 3, 4, 5
>> UnsafeError: setting slice required tuple to be resized beyond current memory allocation. Enter an unsafe context to allow this.
This is overrideable with an unsafe() context.
from einspect import view
tup = (1, 2)
v = view(tup)
with v.unsafe():
v: = 1, 2, 3, 4, 5
print(tup)
>> (1, 2, 3, 4, 5)
>>
/r/Python
https://redd.it/10e80md
An open source Python project CI pipeline
https://brntn.me/blog/open-source-python-ci/
/r/Python
https://redd.it/10e38v0
https://brntn.me/blog/open-source-python-ci/
/r/Python
https://redd.it/10e38v0
brntn.me
Brenton Cleeland - An open source Python project CI pipeline
Personal site of Brenton Cleeland
Best/recommended road map for python beginner?? already met with the basics and now don't know what to start and where to start, just started python for job opportunities and now feeling energetic learning it but don't know what to do next
/r/Python
https://redd.it/10e39zq
/r/Python
https://redd.it/10e39zq
reddit
Best/recommended road map for python beginner?? already met with...
Posted in r/Python by u/Icy_Software_5919 • 9 points and 18 comments
GPTalk : free and open-source Python app to interact with GPT using your voice, in any language
https://github.com/0ut0flin3/GPTalk
/r/Python
https://redd.it/10e78u2
https://github.com/0ut0flin3/GPTalk
/r/Python
https://redd.it/10e78u2
GitHub
GitHub - 0ut0flin3/Talk2GPT: GPT-3 client for Windows and Unix with memories management that supports both text and speech in any…
GPT-3 client for Windows and Unix with memories management that supports both text and speech in any language. Includes a free text2image - 0ut0flin3/Talk2GPT
CDF and PMF of binomial function not same with extreme values
Hello,
I wanted to calculate the chance that I inhale at least one molecule of Ceasars words (see here). I thought to calculate the chance of inhaling zero molecules and distract this value from 1 [1-(binom(0,n,p)\]
I used this code
My output is
When I do normal values my output is the same
How is this possible?
/r/pystats
https://redd.it/10e8bvx
Hello,
I wanted to calculate the chance that I inhale at least one molecule of Ceasars words (see here). I thought to calculate the chance of inhaling zero molecules and distract this value from 1 [1-(binom(0,n,p)\]
I used this code
from scipy.stats import binom def calculate(n, p, r): print (f"{n=} {p=} {r=}") print (f"PMF The chance that you inhale {r} molecules {binom.pmf(r, n, p)}") print (f"CDF The chance that you inhale {r} molecules {binom.cdf(r, n, p)}") n = 25.0*10**21 p = 1.0*10**-21 r = 0 calculate(n, p, r) My output is
PMF The chance that you inhale 0 molecules 1.0CDF The chance that you inhale 0 molecules 1.388794386496407e-11When I do normal values my output is the same
n=10 p=0.1 r=0PMF The chance that you inhale 0 molecules 0.3486784401000001CDF The chance that you inhale 0 molecules 0.34867844009999993How is this possible?
/r/pystats
https://redd.it/10e8bvx
the Guardian
Caesar’s Last Breath: The Epic Story of the Air Around Us – review
Sam Kean’s history of Earth’s atmospheric gases is provocative and entertaining