Turn your Click CLI into a TUI with a two-line change
https://github.com/Textualize/trogon
/r/Python
https://redd.it/13nv4a7
https://github.com/Textualize/trogon
/r/Python
https://redd.it/13nv4a7
GitHub
GitHub - Textualize/trogon: Easily turn your Click CLI into a powerful terminal application
Easily turn your Click CLI into a powerful terminal application - Textualize/trogon
Serve static files with compression/decompression?
I have a flask app that will serve static swf and mp3 files. Some of them are ~25 each. They are served as a batch. What options do I have to speed up the transfer via compression on flask side and definition at the endpoint?
/r/flask
https://redd.it/13nzge5
I have a flask app that will serve static swf and mp3 files. Some of them are ~25 each. They are served as a batch. What options do I have to speed up the transfer via compression on flask side and definition at the endpoint?
/r/flask
https://redd.it/13nzge5
Reddit
r/flask on Reddit: Serve static files with compression/decompression?
Posted by u/Gunplexityyy - 2 votes and 6 comments
Most efficient way of using cursor connections
I have a database and have multiple endpoints where each endpoint makes a specific DB query of its own. Now if we open and close connections on each endpoint, that would be too resource heavy.
Is there a way where we can open a connection for each user once and let him visit all the endpoints without re-opening/closing cursors? Like so:
conn = connection.open()
@app.route('/')
def home():
# some db execution
@app.route('/new', methods='POST')
def new():
# some other db execution
# and then close the cursor once a user is not there any longer
or we need to open and close cursors on every endpoint?
If there is a library to do so, then too I would like to know how it is handling cursors
# Edit:
I just learned about connection pooling. That answers everything
/r/flask
https://redd.it/13mnpro
I have a database and have multiple endpoints where each endpoint makes a specific DB query of its own. Now if we open and close connections on each endpoint, that would be too resource heavy.
Is there a way where we can open a connection for each user once and let him visit all the endpoints without re-opening/closing cursors? Like so:
conn = connection.open()
@app.route('/')
def home():
# some db execution
@app.route('/new', methods='POST')
def new():
# some other db execution
# and then close the cursor once a user is not there any longer
or we need to open and close cursors on every endpoint?
If there is a library to do so, then too I would like to know how it is handling cursors
# Edit:
I just learned about connection pooling. That answers everything
/r/flask
https://redd.it/13mnpro
Reddit
r/flask on Reddit: Most efficient way of using cursor connections
Posted by u/lofi_thoughts - 2 votes and 2 comments
How do I avoid MySQL/SQLAlchemy connection timeouts on a production server?
I have a Flask application server running on A2Hosting. An SQLAlchemy engine is created upon application launch:
As a consequence, every day I'll be greeted with this error in my logs when I access the Website:
I deduce that this error is probably due to a connection timeout, although I cannot confirm this.
It's only mildly annoying because when I try my backend call again, everything proceeds as normal.
Obviously, it'd be nice if this didn't happen when the app is released to the public.
What should I do instead?
/r/flask
https://redd.it/13l8fw7
I have a Flask application server running on A2Hosting. An SQLAlchemy engine is created upon application launch:
engine = create_engine("mysql+pymysql://{}:{}@{}:{}/{}".format( db_uname, db_pswd, db_host, "3306", db_name))As a consequence, every day I'll be greeted with this error in my logs when I access the Website:
sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")I deduce that this error is probably due to a connection timeout, although I cannot confirm this.
It's only mildly annoying because when I try my backend call again, everything proceeds as normal.
Obviously, it'd be nice if this didn't happen when the app is released to the public.
What should I do instead?
/r/flask
https://redd.it/13l8fw7
Reddit
r/flask on Reddit: How do I avoid MySQL/SQLAlchemy connection timeouts on a production server?
Posted by u/Comprehensive-Ad3963 - 2 votes and 7 comments
How to add another kernel to jupyter lite online notebook?
I am not a coder. I am just taking data science classes. I want to use Jupyter on my own. I have a problem. I want the python 3 kernel, but jupyter only has 2 other kernels. Im trying to import a module but the other 2 kernels don't have it. thanks.
/r/JupyterNotebooks
https://redd.it/13ocaxe
I am not a coder. I am just taking data science classes. I want to use Jupyter on my own. I have a problem. I want the python 3 kernel, but jupyter only has 2 other kernels. Im trying to import a module but the other 2 kernels don't have it. thanks.
/r/JupyterNotebooks
https://redd.it/13ocaxe
Reddit
r/JupyterNotebooks on Reddit: How to add another kernel to jupyter lite online notebook?
Posted by u/Disastrous-Field-906 - No votes and 1 comment
How can I have two 'static' folders for 2 containers (each running a flask app) behind the same reverse proxy?
I have a docker, with 3 containers. One running nginx and two python containers serving with uwsgi and each having a flask app.
Before only one of the python containers needed to access the /static/ folder but now they both need to but /static/ is mapped to one of them in nginx.conf. How can I make it so each python container can access their own static folder with :
{{ urlfor('static', filename='script.js') }}
this is the nginx.conf:
http {
server {
include uwsgiparams;
include mime.types;
servertokens off;
proxyhideheader X-Powered-By;
addheader Content-Security-Policy "default-src 'self' cdn.jsdelivr.net code.jquery.com; frame-ancestors 'self'; form-action 'self';";
addheader X-Frame-Options SAMEORIGIN;
addheader X-Content-Type-Options nosniff;
addheader Referrer-Policy "no-referrer";
addheader Permissions-Policy "geolocation=(),midi=(),sync-xhr=(),microphone=(),camera=(),magnetometer=(),gyroscope=(),fullscreen=(self),payment=()";
/r/flask
https://redd.it/13od98c
I have a docker, with 3 containers. One running nginx and two python containers serving with uwsgi and each having a flask app.
Before only one of the python containers needed to access the /static/ folder but now they both need to but /static/ is mapped to one of them in nginx.conf. How can I make it so each python container can access their own static folder with :
{{ urlfor('static', filename='script.js') }}
this is the nginx.conf:
http {
server {
include uwsgiparams;
include mime.types;
servertokens off;
proxyhideheader X-Powered-By;
addheader Content-Security-Policy "default-src 'self' cdn.jsdelivr.net code.jquery.com; frame-ancestors 'self'; form-action 'self';";
addheader X-Frame-Options SAMEORIGIN;
addheader X-Content-Type-Options nosniff;
addheader Referrer-Policy "no-referrer";
addheader Permissions-Policy "geolocation=(),midi=(),sync-xhr=(),microphone=(),camera=(),magnetometer=(),gyroscope=(),fullscreen=(self),payment=()";
/r/flask
https://redd.it/13od98c
Reddit
r/flask on Reddit: How can I have two 'static' folders for 2 containers (each running a flask app) behind the same reverse proxy?
Posted by u/Pickinanameainteasy - 1 vote and no comments
Monday Daily Thread: Project ideas!
Comment any project ideas beginner or advanced in this thread for others to give a try! If you complete one make sure to reply to the comment with how you found it and attach some source code! If you're looking for project ideas, you might be interested in checking out Al Sweigart's, "The Big Book of Small Python Projects" which provides a list of projects and the code to make them work.
/r/Python
https://redd.it/13oakho
Comment any project ideas beginner or advanced in this thread for others to give a try! If you complete one make sure to reply to the comment with how you found it and attach some source code! If you're looking for project ideas, you might be interested in checking out Al Sweigart's, "The Big Book of Small Python Projects" which provides a list of projects and the code to make them work.
/r/Python
https://redd.it/13oakho
Reddit
r/Python on Reddit: Monday Daily Thread: Project ideas!
Posted by u/Im__Joseph - 2 votes and no comments
Raspberry Pi Debuts a Code Editor for Young People: "Python is the preferred coding language for beginners (particularly young people), as it’s the most intuitive language utilized by professionals. For this reason, Raspberry Pi’s Code Editor uses Python (specifically the standard library and P5)."
https://www.reviewgeek.com/150725/raspberry-pi-debuts-a-code-editor-for-young-people/
/r/Python
https://redd.it/13o040f
https://www.reviewgeek.com/150725/raspberry-pi-debuts-a-code-editor-for-young-people/
/r/Python
https://redd.it/13o040f
Reviewgeek
Raspberry Pi Debuts a Code Editor for Young People
Teaching a child or a teenager to code can give them a sense of pride, or even put them on track for a career in technology. That’s why the Raspberry Pi Foundation is now launching its online Code Editor in beta. It’s a free and simple tool that lets you…
Cuid2 - Secure, collision-resistant ids optimized for horizontal scaling and performance. Next generation UUIDs.
I've just released v2.0.0 of my cuid2 python port. The original cuid2 package comes from JS world by ParallelDrive. They have a lot of the reasons to use Cuid2 posted in their repo, including
Secure: It's not feasible to guess the next id, existing valid ids, or learn anything about the referenced data from the id. Cuid2 uses multiple, independent entropy sources and hashes them with a security-audited, NIST-standard cryptographically secure hashing algorithm (Sha3).
Collision resistant: It's extremely unlikely to generate the same id twice (by default, you'd need to generate roughly 4,000,000,000,000,000,000 ids (sqrt(36^(24-1) 26) = 4.0268498e+18) to reach 50% chance of collision.
Horizontally scalable: Generate ids on multiple machines without coordination.
Offline-compatible: Generate ids without a network connection.
URL and name-friendly: No special characters.
Fast and convenient: No async operations. Won't introduce user-noticeable delays. Less than 5k, gzipped.
But not too fast: If you can hash too quickly you can launch parallel attacks to find duplicates or break entropy-hiding. For unique ids, the fastest runner loses the security race.
You can find the source code of my package here: https://github.com/gordon-code/cuid2
And install it with
When doing my own research on UUID replacements, I came across another of
/r/django
https://redd.it/13nyey6
I've just released v2.0.0 of my cuid2 python port. The original cuid2 package comes from JS world by ParallelDrive. They have a lot of the reasons to use Cuid2 posted in their repo, including
Secure: It's not feasible to guess the next id, existing valid ids, or learn anything about the referenced data from the id. Cuid2 uses multiple, independent entropy sources and hashes them with a security-audited, NIST-standard cryptographically secure hashing algorithm (Sha3).
Collision resistant: It's extremely unlikely to generate the same id twice (by default, you'd need to generate roughly 4,000,000,000,000,000,000 ids (sqrt(36^(24-1) 26) = 4.0268498e+18) to reach 50% chance of collision.
Horizontally scalable: Generate ids on multiple machines without coordination.
Offline-compatible: Generate ids without a network connection.
URL and name-friendly: No special characters.
Fast and convenient: No async operations. Won't introduce user-noticeable delays. Less than 5k, gzipped.
But not too fast: If you can hash too quickly you can launch parallel attacks to find duplicates or break entropy-hiding. For unique ids, the fastest runner loses the security race.
You can find the source code of my package here: https://github.com/gordon-code/cuid2
And install it with
$ pipx install cuid2
When doing my own research on UUID replacements, I came across another of
/r/django
https://redd.it/13nyey6
GitHub
GitHub - paralleldrive/cuid2: The most secure, collision-resistant ids optimized for horizontal scaling and performance.
The most secure, collision-resistant ids optimized for horizontal scaling and performance. - paralleldrive/cuid2
DRF views across multiple tables
I've written an API using DRF to help with tracking multiple deployments of an app with different configurations, so I have about half-a-dozen models with many-to-many relationships between each. Here's an example of one of my models:
class Package(models.Model):
engine = models.ForeignKey(Engine, on_delete=models.CASCADE)
ruleset = models.ForeignKey(Ruleset, on_delete=models.CASCADE)
configuration = models.ForeignKey(Configuration, on_delete=models.CASCADE)
created = models.DateTimeField(auto_now_add=True)
Each of the Engine, Ruleset and Configuration models has a name field. I was able to get the API running very quickly, the problem is that DRF expects that if I create a new package entry that I should supply the ID numbers for each of engine, ruleset and configuration. Is there a way I can allow the user / client to supply the name for each instead?
Similarly, when accessing in the browser, the view for Package just shows the ids of the other pieces and the form wants me to pick from a list of ids instead of names. Do I need to write a custom view and form myself to be able to see
/r/django
https://redd.it/13om7y0
I've written an API using DRF to help with tracking multiple deployments of an app with different configurations, so I have about half-a-dozen models with many-to-many relationships between each. Here's an example of one of my models:
class Package(models.Model):
engine = models.ForeignKey(Engine, on_delete=models.CASCADE)
ruleset = models.ForeignKey(Ruleset, on_delete=models.CASCADE)
configuration = models.ForeignKey(Configuration, on_delete=models.CASCADE)
created = models.DateTimeField(auto_now_add=True)
Each of the Engine, Ruleset and Configuration models has a name field. I was able to get the API running very quickly, the problem is that DRF expects that if I create a new package entry that I should supply the ID numbers for each of engine, ruleset and configuration. Is there a way I can allow the user / client to supply the name for each instead?
Similarly, when accessing in the browser, the view for Package just shows the ids of the other pieces and the form wants me to pick from a list of ids instead of names. Do I need to write a custom view and form myself to be able to see
/r/django
https://redd.it/13om7y0
Reddit
r/django on Reddit: DRF views across multiple tables
Posted by u/wolfson109 - No votes and 1 comment
How to conditional in HTMX Partials ?
## How to conditional in HTMX Partials ?
/htmx/foo
/dashboard
/r/django
https://redd.it/13oo5bz
## How to conditional in HTMX Partials ?
/htmx/foo
html
{% if request.user.is_superuser %}
<a>Admin Partials</a>
{% elif request.user.role == "role_a" %}
<a>A Partials</a>
{% elif request.user.role == "role_b" %}
<a>Admin Partials</a>
{% else %}
<a>Reguler Partials</a>
{% endif %}
/dashboard
html
<div hx-get="/htmx/foo">
</div>
/r/django
https://redd.it/13oo5bz
Reddit
r/django on Reddit: How to conditional in HTMX Partials ?
Posted by u/mad-skidipap - No votes and no comments
Yay! I can officially join this subreddit now!
​
Source Code:
https://preview.redd.it/hwvn9xrcvc1b1.png?width=1157&format=png&auto=webp&v=enabled&s=f62ff30e00038982b4a14bce89771672c3c40a53
Source code:
print("Hello World")
Thanks to the resources provided by the community (all of you), you have made it easy for me to start my programming journey.
/r/Python
https://redd.it/13omgv8
​
Source Code:
https://preview.redd.it/hwvn9xrcvc1b1.png?width=1157&format=png&auto=webp&v=enabled&s=f62ff30e00038982b4a14bce89771672c3c40a53
Source code:
print("Hello World")
Thanks to the resources provided by the community (all of you), you have made it easy for me to start my programming journey.
/r/Python
https://redd.it/13omgv8
Flask and WebSocket - Real-Time Message exchange
Just wanted to share the first "real" (apart from the tutorials) project that I have created using Flask and using WebSocket (thru Flask-SocketIO).
I transformed my Raspberry Pi into a local "IoT hub" where I am reading several sensors and displaying them in real-time thru a Flask Web Application. I am receiving sensor readings every second and display them using the web application I created.
I am surprised by how easy it is to use WebSocket in Flask.
​
Real-Time Temperature\/Humidity Dashboard using Python, Flask, and Flask-SocketIO
I have never used Bootstrap in an actual project but tried exploring it here and I think I like the outcome.
Maybe you are interested in looking.
Code: https://github.com/donskytech/dht22-weather-station-python-flask-socketio-multiple-sensors
/r/flask
https://redd.it/13ootfw
Just wanted to share the first "real" (apart from the tutorials) project that I have created using Flask and using WebSocket (thru Flask-SocketIO).
I transformed my Raspberry Pi into a local "IoT hub" where I am reading several sensors and displaying them in real-time thru a Flask Web Application. I am receiving sensor readings every second and display them using the web application I created.
I am surprised by how easy it is to use WebSocket in Flask.
​
Real-Time Temperature\/Humidity Dashboard using Python, Flask, and Flask-SocketIO
I have never used Bootstrap in an actual project but tried exploring it here and I think I like the outcome.
Maybe you are interested in looking.
Code: https://github.com/donskytech/dht22-weather-station-python-flask-socketio-multiple-sensors
/r/flask
https://redd.it/13ootfw
Show certain navbar options if user is logged in.
I am trying to have the navbar on my app show Home and Logout if the user is logged in and Home, Login and sign-up if the user is not.
Here is my current code:
It currently shows Home/Login/Sign-up if you are not logged (which is what i want), but when you are logged in it still shows the same.
/r/flask
https://redd.it/13ktva7
I am trying to have the navbar on my app show Home and Logout if the user is logged in and Home, Login and sign-up if the user is not.
Here is my current code:
<div class="navbar-nav"> {% if current_user.is_authenticated %} <a class="nav-item nav-link" id="home" href="/">Home</a> <a class="nav-item nav-link" id="logout" href="/logout">Logout</a> {% else %} <a class="nav-item nav-link" id="home" href="/">Home</a> <a class="nav-item nav-link" id="login" href="/login">Login</a> <a class="nav-item nav-link" id="signup" href="/signup">Sing-up</a> {% endif %} </div>It currently shows Home/Login/Sign-up if you are not logged (which is what i want), but when you are logged in it still shows the same.
/r/flask
https://redd.it/13ktva7
Reddit
r/flask on Reddit: Show certain navbar options if user is logged in.
Posted by u/NoisyCrusthead - 4 votes and 4 comments
Routes in Flask
Hello, I'm a beginner to Flask, and am trying to build an app, using a React frontend and a Flask backend. I'm having a little difficulty figuring out how to structure my app. If I have a button, and I want to make a call to my API on click, would I create a separate route for that button, or would it use the same route as that entire page, with a specified GET request?
Thank you for the help
/r/flask
https://redd.it/13kisfa
Hello, I'm a beginner to Flask, and am trying to build an app, using a React frontend and a Flask backend. I'm having a little difficulty figuring out how to structure my app. If I have a button, and I want to make a call to my API on click, would I create a separate route for that button, or would it use the same route as that entire page, with a specified GET request?
Thank you for the help
/r/flask
https://redd.it/13kisfa
Reddit
r/flask on Reddit: Routes in Flask
Posted by u/MapleMooseAttack - 2 votes and 14 comments
Trouble with user registration
I'm new to Django and Django rest framework. I'm following a tutorial/guide that is React frontend, django backend, and with redux as well. I've come across a problem is that when I'm registering a new user, I get an error telling me that the new user I'm trying to create already has an email that exist (which isn't true). However, that user still does get successfully registered, but I don't get automatically logged in with that new user.
Github repository: https://github.com/ngc918/dr-ecommerce
Stack overflow post: https://stackoverflow.com/questions/76302475/react-django-user-register-gives-me-400-bad-request/76303168#76303168
/r/djangolearning
https://redd.it/13otsxo
I'm new to Django and Django rest framework. I'm following a tutorial/guide that is React frontend, django backend, and with redux as well. I've come across a problem is that when I'm registering a new user, I get an error telling me that the new user I'm trying to create already has an email that exist (which isn't true). However, that user still does get successfully registered, but I don't get automatically logged in with that new user.
Github repository: https://github.com/ngc918/dr-ecommerce
Stack overflow post: https://stackoverflow.com/questions/76302475/react-django-user-register-gives-me-400-bad-request/76303168#76303168
/r/djangolearning
https://redd.it/13otsxo
GitHub
GitHub - ngc918/dr-ecommerce
Contribute to ngc918/dr-ecommerce development by creating an account on GitHub.
How run a daily scraper with Django?
I'd like to set up an application where users input a URL (or multiple URLs), and then once per day my application scrapes that URL. I was wondering how that setup might look, because I've done scraping before, and I've made Django apps, but never tried to make a scraper that lives in a Django app. Thanks for any tips!
/r/django
https://redd.it/13osnul
I'd like to set up an application where users input a URL (or multiple URLs), and then once per day my application scrapes that URL. I was wondering how that setup might look, because I've done scraping before, and I've made Django apps, but never tried to make a scraper that lives in a Django app. Thanks for any tips!
/r/django
https://redd.it/13osnul
Reddit
r/django on Reddit: How run a daily scraper with Django?
Posted by u/breadgirl42 - 12 votes and 16 comments
File path methods not working
Hello all,
currently experiencing issues importing data. Ive already tried/ read numerous S.O suggestions and none seem to work
File path: "C:\\Users\\marvi\\OneDrive\\Desktop\\MR WOLF\\MR_WOLF_DUMMY_DATA.csv"
import csv
import os
import matplotlib.pyplot as plt
import numpy as np
from sklearn.modelselection import traintestsplit
from sklearn.linearmodel import LogisticRegression
from sklearn.preprocessing import OneHotEncoder, LabelEncoder
from sklearn.metrics import meansquarederror
from sklearn.modelselection import crossvalscore
from sklearn.metrics import classificationreport, confusionmatrix
from sklearn import preprocessing
from math import sqrt
import pandas as pd
**READ DATA**
data = open(r"C:\Users\marvi\OneDrive\Desktop\MR WOLF\MRWOLFDUMMYDATA.csv")
data = pd.readcsv(path)
data.dtypes
which in turn returns
---------------------------------------------------------------------------
FileNotFoundError Traceback (most recent call last)
<ipython-input-7-a0d52672e39f> in <cell line: 1>()
----> 1 data = open(r"C:\Users\marvi\OneDrive\Desktop\MR WOLF\MRWOLFDUMMYDATA.csv")
/r/JupyterNotebooks
https://redd.it/13ortum
Hello all,
currently experiencing issues importing data. Ive already tried/ read numerous S.O suggestions and none seem to work
File path: "C:\\Users\\marvi\\OneDrive\\Desktop\\MR WOLF\\MR_WOLF_DUMMY_DATA.csv"
import csv
import os
import matplotlib.pyplot as plt
import numpy as np
from sklearn.modelselection import traintestsplit
from sklearn.linearmodel import LogisticRegression
from sklearn.preprocessing import OneHotEncoder, LabelEncoder
from sklearn.metrics import meansquarederror
from sklearn.modelselection import crossvalscore
from sklearn.metrics import classificationreport, confusionmatrix
from sklearn import preprocessing
from math import sqrt
import pandas as pd
**READ DATA**
data = open(r"C:\Users\marvi\OneDrive\Desktop\MR WOLF\MRWOLFDUMMYDATA.csv")
data = pd.readcsv(path)
data.dtypes
which in turn returns
---------------------------------------------------------------------------
FileNotFoundError Traceback (most recent call last)
<ipython-input-7-a0d52672e39f> in <cell line: 1>()
----> 1 data = open(r"C:\Users\marvi\OneDrive\Desktop\MR WOLF\MRWOLFDUMMYDATA.csv")
/r/JupyterNotebooks
https://redd.it/13ortum
Reddit
[deleted by user] : r/JupyterNotebooks
4K subscribers in the JupyterNotebooks community. The Jupyter notebook is a web application that allows users of multiple programming languages to…
Basic html not rendering
Hi I'm trying to learn flask and I have to admit it's not going well, I'm stuck on the very first thing, for some reason I can't get render template to work. What can I possibly be doing wrong?
from flask import Flask, redirect, url_for, render_template
app = Flask(__name__)
@app.route("/")
def index():
return render_template("index.html")
if __name__ == "__main__":
app.run(debug=True)
html is in templates folder as index.html and simply looks like this:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Home Page</title>
</head>
<body>
<h1>Home Page</h1>
<p>Hello!</p>
</body>
</html>
As basic as you can get, but it just returns a blank screen. So
/r/flask
https://redd.it/13p54iw
Hi I'm trying to learn flask and I have to admit it's not going well, I'm stuck on the very first thing, for some reason I can't get render template to work. What can I possibly be doing wrong?
from flask import Flask, redirect, url_for, render_template
app = Flask(__name__)
@app.route("/")
def index():
return render_template("index.html")
if __name__ == "__main__":
app.run(debug=True)
html is in templates folder as index.html and simply looks like this:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Home Page</title>
</head>
<body>
<h1>Home Page</h1>
<p>Hello!</p>
</body>
</html>
As basic as you can get, but it just returns a blank screen. So
/r/flask
https://redd.it/13p54iw
Reddit
r/flask on Reddit: Basic html not rendering
Posted by u/tgbnju - 2 votes and 7 comments
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/13p7vlm
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/13p7vlm
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
Deploying a flask app to Heroku - timeout due to webscraping
Hi! (Just to preface, i'm a complete beginner with coding and deploying to heroku.)
Im attempting to deploy a python flask app which uses web scraping to gather words from the news. Im using serpapi for the web scraping and Redis to store on a database after the initial loading of the page. The problem is I can't get past the initial load because Heroku is giving me a timeout error.
specifically:
2023-05-22T18:12:58.846289+00:00 heroku[router\]: at=error code=H12desc="Request timeout" method=GET path="/" host=my-app-name.herokuapp.com request_id=d52dd5be-626a-43c0-bd01-1544f32c9bb1 fwd="86.16.228.212" dyno=web.1 connect=0ms service=30000ms status=503 bytes=0 protocol=https
I tried adding a timeout to my Procfile: web: gunicorn app:app --timeout 240
But nothing changed and im still getting the timeout error. I tried troubleshooting with GPT and it suggested using celery. Is this my only option? Any other suggestions are welcome!! When running locally, the webscraping usually on initial load takes a couple of minutes (max) as it is searching the first 100 results of google news and also performing sentiment analysis on the words.
I also posted this to r/heroku but thought to also post it here as its a larger community. Again, im a total beginner and this is my first project, so please go easy if this is an obvious fix or if
/r/flask
https://redd.it/13ozx9o
Hi! (Just to preface, i'm a complete beginner with coding and deploying to heroku.)
Im attempting to deploy a python flask app which uses web scraping to gather words from the news. Im using serpapi for the web scraping and Redis to store on a database after the initial loading of the page. The problem is I can't get past the initial load because Heroku is giving me a timeout error.
specifically:
2023-05-22T18:12:58.846289+00:00 heroku[router\]: at=error code=H12desc="Request timeout" method=GET path="/" host=my-app-name.herokuapp.com request_id=d52dd5be-626a-43c0-bd01-1544f32c9bb1 fwd="86.16.228.212" dyno=web.1 connect=0ms service=30000ms status=503 bytes=0 protocol=https
I tried adding a timeout to my Procfile: web: gunicorn app:app --timeout 240
But nothing changed and im still getting the timeout error. I tried troubleshooting with GPT and it suggested using celery. Is this my only option? Any other suggestions are welcome!! When running locally, the webscraping usually on initial load takes a couple of minutes (max) as it is searching the first 100 results of google news and also performing sentiment analysis on the words.
I also posted this to r/heroku but thought to also post it here as its a larger community. Again, im a total beginner and this is my first project, so please go easy if this is an obvious fix or if
/r/flask
https://redd.it/13ozx9o
Reddit
r/flask on Reddit: Deploying a flask app to Heroku - timeout due to webscraping
Posted by u/flowerpotlil - 3 votes and 13 comments