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
How to setup a permanent session in default Flask?

If I use Flask-Session to store session data server-side, it is as easy as passing SESSION_PERMANENT = False (not default Flask, unique to Flask-Session) to the app.config, then set the desired expiration time with , PERMANENT_SESSION_LIFETIME = desired_exp_time which is default Flask config.

If I use default Flask to store session data client-side, I need to set PERMANENT_SESSION_LIFETIME = desired_exp_time first, then state session.permanent = True in the request (ex. u/app.route), else I get this error: RuntimeError: Working outside of request context. The docs is somewhat unclear about how to implement, see here.

What I don't understand is how to setup the default Flask one. I tried to google, and found this in Stack Overflow. The accepted answer suggests setting it with before\_request, but I think why every request, we need to set session.permanent = True?

1. How to set permanent sessions in default flask properly? Where to set it?
2. Can you toggle permanent and non permanent session?
3. What should we do after session is expired? What about the session data?

/r/flask
https://redd.it/1gdur94
Flask Async Mail

🚀 Introducing Flask-Async-Mail! 📧

Hey everyone! I just released Flask-Async-Mail, a lightweight and flexible asynchronous email-sending library for Flask apps using Celery. 🎉

🔹 Features:
Supports both synchronous & asynchronous email sending
Works with Celery & Redis
Supports plaintext & HTML emails
Simple setup & easy integration with Flask

👉 Try it out & contribute!
📦 PyPI: https://pypi.org/project/flask-async-mail/
💻 GitHub: https://github.com/manitreasure1/flas-async-mail.git

I’d love your feedback, contributions, and stars on GitHub! Let’s build something awesome together. 🚀🔥

\#Flask #Python #Async #Email #OpenSource

/r/flask
https://redd.it/1j10wib
Need Career Advice: Stuck in .NET Web Forms, Should I Switch to Python Flask?

Hi everyone,

I’ve been working at a company for the past 4 months. I was hired to work on a .NET Web Forms project, but the pace of work is extremely slow. For the last 3 months, I haven’t written any real code — I’ve just been learning about Web Forms.

The company is saying they’ll give me actual work on an ERP project starting next week, but honestly, I’m not feeling confident. I’ve been told there will be no proper mentorship or guidance, and I find ERP systems really hard to grasp.

On the other hand, I’m passionate about innovation and working with new technologies. I really enjoy Python and I’ve been considering switching over to Flask development instead, since it aligns more with what I want to do in the future.

I’m feeling a lot of stress and confusion right now. Should I stick it out with this company and the ERP/.NET stuff, or should I start focusing on Python Flask and make a shift in that direction?

Any advice from experienced developers would be really appreciated. Thanks!

\#CareerAdvice #DotNet #Python #Flask #ERP #WebForms #JuniorDeveloper #ProgrammingHelp

/r/flask
https://redd.it/1mbebbe
app.run() not recommended for development server?

For me it would be convenient to run the Flask development server with Flask.run() however the documentation says:

> It is not recommended to use this function for development with automatic reloading as this is badly supported. Instead you should be using the flask command line script’s run support.

Documentation link: https://flask.palletsprojects.com/en/stable/api/#flask.Flask.run

Instead they suggest to use the command line flask run which I currently do.

But I wonder how its different. Why is Flask.run not recommended?

/r/flask
https://redd.it/1p9t86o