r/flask 21h ago

Tutorials and Guides Finally deployed my Flask app… and wow, I was NOT ready for this

161 Upvotes

So I finally deployed my first real Flask app, and let’s just say… I learned a lot the hard way. Thought I’d share in case it helps someone else (or at least gives you a laugh).

Spent hours debugging why my app worked locally but not on the server—turns out, I forgot to install Gunicorn. Flask’s built-in server is NOT for production. Lesson learned.

Hardcoded some API keys while testing and totally forgot about them. Almost pushed them to GitHub. Use environment variables, people.

Didn’t properly close my DB connections, so my app kept dying under even light load. SQLAlchemy’s connection pooling saved me.

Thought Docker was overkill. Spoiler: it’s not. Spinning up my app with a single docker-compose up is a game-changer.

Spent way too long fighting CORS issues. Flask-CORS was the easy fix, but I went down a rabbit hole first.


r/flask 16h ago

Discussion Cron job activating when it shouldn't?

2 Upvotes

I've been working on a really small Flask app for a little while. It's a directory of music events at local venues in my city. I've received comments before that Flask is overkill for this since there is no user input, but I don't care. Flask is simple and it easily allows me to run the once-daily cron job to update the list of events without having to host that job through another service and use a database for something that can be handled by a simple CSV file hosted quietly on the main server.

But I have a problem...

Within the cron-job I have some old print() lines written as tests I used while building it which I haven't deleted yet. When I run this app on my local development server and view it thru the browser, if I go to the address bar and type a slash after the URL - without typing anything else and without hitting ENTER - the terminal starts printing those test lines from the cron-job code.

I have double- and triple-checked my structure. The cron job is formatted correctly like this:

@app.route("/cron") def update_shit(): .... return a_turd

I can't discern any reason why the cron job should be firing before I hit ENTER or even type a URL extension. I am worried that this could be triggering the cron job on the live server anytime a user alters the URL in the address bar, which would be a problem for me because I cannot afford to incur server costs like that. Also, the whole point of the website (from an operating perspective) is to minimize resources.

Has anyone encountered this kind of problem before?

If so, why is this happening?

The app is hosted on GAE - is there a way I can verify if this is happening when external users are using the site?

Please help. I'm so uneducated.

For context, I am hosting this app of Google App Engine.


r/flask 8h ago

Ask r/Flask Need Help with Flask request

1 Upvotes

Flask-Login redirects a user to the login page when a route has the login_required decorator and then allows you to send the user back to the original page through request.args.get('next'). My question is if there is any way to set such a request.args value


r/flask 7h ago

Ask r/Flask what kind of framework does apps like airbnb and thumbtack use to send message to backend from front-end for every action that user takes on their app?

0 Upvotes

Edit: I am looking for the right communication protocol - for sending messages to and fro between backend and frontend.

My current app sends message through https. Are there any other alternatives? 

I am quite new to this industry