How deploy a Django app?
I'm very close to finish my django project and I'm worried about the deploy. So far, I have an EC2 instance in AWS and even tough it's "online", it's just the EC2 running "python3 manage.py runserver" all the time.
I know this is not the best way, so I wanted to ask you guys:
\-How should I manage my Media/Static files?
\-How should I manage the DB?
\-How should I keep running the app?
\-How can I keep my code updated with my repo in github?
I'm pretty newbie in this deployment field, so I'll appreciate your help and comments :D
/r/django
https://redd.it/188g1k8
I'm very close to finish my django project and I'm worried about the deploy. So far, I have an EC2 instance in AWS and even tough it's "online", it's just the EC2 running "python3 manage.py runserver" all the time.
I know this is not the best way, so I wanted to ask you guys:
\-How should I manage my Media/Static files?
\-How should I manage the DB?
\-How should I keep running the app?
\-How can I keep my code updated with my repo in github?
I'm pretty newbie in this deployment field, so I'll appreciate your help and comments :D
/r/django
https://redd.it/188g1k8
Reddit
From the django community on Reddit
Explore this post and more from the django community
django-unfold charts
Does anyone know what charts Django-Unfold uses? I love how they look!
/r/django
https://redd.it/188ntjk
Does anyone know what charts Django-Unfold uses? I love how they look!
/r/django
https://redd.it/188ntjk
Reddit
From the django community on Reddit
Explore this post and more from the django community
PyCharm docker-compose interpreter in WSL
Hey everyone! New coder here.
Building my first web app, I started out with venv in WSL. That worked great for the first 2 months but I've since brought Celery, Mailpit, Redis, and Flower into the equation, which made it very tedious to manage everything manually, so I learned Docker and dockerized my app (I now love Docker, btw :D).
For development, I use Docker Desktop with the WSL-based engine and everything's fine except that I can't configure the Python interpreter in PyCharm to use docker-compose in WSL. The functionality is there but after hooking it all up, it fails with the following errors:
​
https://preview.redd.it/trw2ktsfop3c1.png?width=737&format=png&auto=webp&s=251bff65b32721112c177bfa7ca77d218d0b81c4
​
https://preview.redd.it/rnayo0ogop3c1.png?width=724&format=png&auto=webp&s=f6ab88afdd27150dcd95312beab1eb604b1dfd19
Over the past 3 days, I've tried reinstalling WSL, Docker Desktop, multiple versions of PyCharm Pro, and seemingly anything in between to no avail.
My question is, has anyone successfully managed to use a Python interpreter hooked to a docker-compose in WSL in PyCharm? I really like PyCharm, but without the above, I can't use the debugger, so I'd probably try running the same setup on native Ubuntu on dual-boot or move to VS Code.
/r/django
https://redd.it/188gb9e
Hey everyone! New coder here.
Building my first web app, I started out with venv in WSL. That worked great for the first 2 months but I've since brought Celery, Mailpit, Redis, and Flower into the equation, which made it very tedious to manage everything manually, so I learned Docker and dockerized my app (I now love Docker, btw :D).
For development, I use Docker Desktop with the WSL-based engine and everything's fine except that I can't configure the Python interpreter in PyCharm to use docker-compose in WSL. The functionality is there but after hooking it all up, it fails with the following errors:
​
https://preview.redd.it/trw2ktsfop3c1.png?width=737&format=png&auto=webp&s=251bff65b32721112c177bfa7ca77d218d0b81c4
​
https://preview.redd.it/rnayo0ogop3c1.png?width=724&format=png&auto=webp&s=f6ab88afdd27150dcd95312beab1eb604b1dfd19
Over the past 3 days, I've tried reinstalling WSL, Docker Desktop, multiple versions of PyCharm Pro, and seemingly anything in between to no avail.
My question is, has anyone successfully managed to use a Python interpreter hooked to a docker-compose in WSL in PyCharm? I really like PyCharm, but without the above, I can't use the debugger, so I'd probably try running the same setup on native Ubuntu on dual-boot or move to VS Code.
/r/django
https://redd.it/188gb9e
What was for you the biggest thing that happened in the Python ecosystem in 2023?
Of course, there was Python 3.12, but I'm not only talking about version releases or libraries but also about projects that got big this year, events, etc...
EDIT : so nobody cared about pandas 2, mojo or python in Excel ?
/r/Python
https://redd.it/188fo2w
Of course, there was Python 3.12, but I'm not only talking about version releases or libraries but also about projects that got big this year, events, etc...
EDIT : so nobody cared about pandas 2, mojo or python in Excel ?
/r/Python
https://redd.it/188fo2w
Reddit
From the Python community on Reddit
Explore this post and more from the Python community
dotenv or config.json
I know both will work, but is it better to access your environment variables (
/r/flask
https://redd.it/188ww9f
I know both will work, but is it better to access your environment variables (
SECRET_KEY, EMAIL_USERNAME, etc) using load_dotenv() or json.load(config_file)? In both cases the variables are being imported from outside the website's folder structure, but is one approach inherently safer than the other? If so, please explain why./r/flask
https://redd.it/188ww9f
Reddit
From the flask community on Reddit
Explore this post and more from the flask community
How to use Flask with SQLAlchemy Core functions?
I found that SQLAlchemy ORM is not what I need, but AFAIK the Flask-SQLAlchemy module is an ORM based one. How can I use SQLAlchemy with Flask without ORM? Is it enough to setup/configure a SQLAlchemy object at the start of app:
db = SQLAlchemy(app)
then get a connection object from it:
conn = db.engine.connect()
and then use it if it was made by the original (non-flask) sqlalchemy?
/r/flask
https://redd.it/187qyzq
I found that SQLAlchemy ORM is not what I need, but AFAIK the Flask-SQLAlchemy module is an ORM based one. How can I use SQLAlchemy with Flask without ORM? Is it enough to setup/configure a SQLAlchemy object at the start of app:
db = SQLAlchemy(app)
then get a connection object from it:
conn = db.engine.connect()
and then use it if it was made by the original (non-flask) sqlalchemy?
/r/flask
https://redd.it/187qyzq
Reddit
From the flask community on Reddit
Explore this post and more from the flask community
2,000 free sign ups available for the "Automate the Boring Stuff with Python" online course. (Dec 2023)
If you want to learn to code, I've released 2,000 free sign ups for my course following my Automate the Boring Stuff with Python book (each has 1,000 sign ups, use the other one if one is sold out):
https://udemy.com/course/automate/?couponCode=DEC2023FREE
https://udemy.com/course/automate/?couponCode=DEC2023FREE2
If you are reading this after the sign ups are used up, you can always find the first 15 of the course's 50 videos are free on YouTube if you want to preview them. YOU CAN ALSO WATCH THE VIDEOS WITHOUT SIGNING UP FOR THE COURSE. All of the videos on the course webpage have "preview" turned on. Scroll down to find and click "Expand All Sections" and then click the preview link. You won't have access to the forums and other materials, but you can watch the videos.
NOTE: Be sure to BUY the course for $0, and not sign up for Udemy's subscription plan. The subscription plan is free for the first seven days and then they charge you. It's selected by default. If you are on a laptop and can't click the BUY checkbox, try shrinking the browser window. Some have reported it works in mobile view.
I'm also working on another Udemy course that follows my recent book "Beyond
/r/Python
https://redd.it/188l3cu
If you want to learn to code, I've released 2,000 free sign ups for my course following my Automate the Boring Stuff with Python book (each has 1,000 sign ups, use the other one if one is sold out):
https://udemy.com/course/automate/?couponCode=DEC2023FREE
https://udemy.com/course/automate/?couponCode=DEC2023FREE2
If you are reading this after the sign ups are used up, you can always find the first 15 of the course's 50 videos are free on YouTube if you want to preview them. YOU CAN ALSO WATCH THE VIDEOS WITHOUT SIGNING UP FOR THE COURSE. All of the videos on the course webpage have "preview" turned on. Scroll down to find and click "Expand All Sections" and then click the preview link. You won't have access to the forums and other materials, but you can watch the videos.
NOTE: Be sure to BUY the course for $0, and not sign up for Udemy's subscription plan. The subscription plan is free for the first seven days and then they charge you. It's selected by default. If you are on a laptop and can't click the BUY checkbox, try shrinking the browser window. Some have reported it works in mobile view.
I'm also working on another Udemy course that follows my recent book "Beyond
/r/Python
https://redd.it/188l3cu
Udemy
Automate the Boring Stuff with Python Programming Course
A practical programming course for office workers, academics, and administrators who want to improve their productivity.
Does Flask-Login 0.7.0 support cookie based authentication? Or is it purely session based? What are the alternatives?
Does Flask-Login 0.7.0 support cookie based authentication? Or is it purely session based? What are the alternatives?
/r/flask
https://redd.it/187iqhp
Does Flask-Login 0.7.0 support cookie based authentication? Or is it purely session based? What are the alternatives?
/r/flask
https://redd.it/187iqhp
Reddit
From the flask community on Reddit
Explore this post and more from the flask community
Flask with UltraJSON
https://pypi.org/project/flask-ujson/
This might be interesting to speed test...
/r/flask
https://redd.it/187o7ju
https://pypi.org/project/flask-ujson/
This might be interesting to speed test...
/r/flask
https://redd.it/187o7ju
PyPI
flask-ujson
Flask with UltraJSON.
i feel overwhelmed , should i start learning django from tutorials first or begin by building projects.
/r/django
https://redd.it/188wr45
/r/django
https://redd.it/188wr45
Reddit
From the django community on Reddit
Explore this post and more from the django community
Flask-login not working after starting program on a different machine? Never matches hash.
I have a program working with Flask-Login for authentication. I have been testing and using it for the last couple of months with no issue with the admin account being able to login and be remembered by the browser.
I now attempt to set up the program from scratch on another machine and I cannot log in even after creating the account.
I have this function:
bcrypt = Bcrypt(app)
def createadminuser(bcryptobj):
password = os.getenv('ADMINPASSWORD')
hashedpw = bcryptobj.generatepasswordhash(password)
if db.session.query(Users).filter(Users.userid == 1).first() is None:
adminuser = Users(
userid=1,
username="admin",
password=hashedpw,
)
db.session.add(adminuser)
db.session.commit()
with app.appcontext():
db.createall('main')
db.createall('config')
createadminuser(bcrypt)
This successfully creates the admin account:
1|admin|$2b$12$3DaNwkdb4rym0r2EMoLR6OCoJj8QpSgcq7gt0yVM9tqGb0HGWNk1a
I have a script to generate the admin password and overwrite the old one if necessary:
if sqlite3 webapp/instance/test.db "SELECT EXISTS(SELECT 1 FROM users WHERE username='admin';"
/r/flask
https://redd.it/186tvxm
I have a program working with Flask-Login for authentication. I have been testing and using it for the last couple of months with no issue with the admin account being able to login and be remembered by the browser.
I now attempt to set up the program from scratch on another machine and I cannot log in even after creating the account.
I have this function:
bcrypt = Bcrypt(app)
def createadminuser(bcryptobj):
password = os.getenv('ADMINPASSWORD')
hashedpw = bcryptobj.generatepasswordhash(password)
if db.session.query(Users).filter(Users.userid == 1).first() is None:
adminuser = Users(
userid=1,
username="admin",
password=hashedpw,
)
db.session.add(adminuser)
db.session.commit()
with app.appcontext():
db.createall('main')
db.createall('config')
createadminuser(bcrypt)
This successfully creates the admin account:
1|admin|$2b$12$3DaNwkdb4rym0r2EMoLR6OCoJj8QpSgcq7gt0yVM9tqGb0HGWNk1a
I have a script to generate the admin password and overwrite the old one if necessary:
if sqlite3 webapp/instance/test.db "SELECT EXISTS(SELECT 1 FROM users WHERE username='admin';"
/r/flask
https://redd.it/186tvxm
Reddit
From the flask community on Reddit
Explore this post and more from the flask community
My first time selling a website.
It's my first time selling a website, how much should I price it?
All this time and I only hosted my projects on free slow services, but since I'm working a full project then I don't where should I host it for the best experience and how much should I charge for it.
The website is a landing page for a startup, and the whole purpose of it is just to view their services.
No payment services, no actual accounts and stuff. Just 2-5 pages max.
I need advice on how much should I charge for it, where to host it, and some details that I may not be aware of. If anyone can help then that'll be great. Thanks already! (I don't know what to flair my post)
/r/django
https://redd.it/18930in
It's my first time selling a website, how much should I price it?
All this time and I only hosted my projects on free slow services, but since I'm working a full project then I don't where should I host it for the best experience and how much should I charge for it.
The website is a landing page for a startup, and the whole purpose of it is just to view their services.
No payment services, no actual accounts and stuff. Just 2-5 pages max.
I need advice on how much should I charge for it, where to host it, and some details that I may not be aware of. If anyone can help then that'll be great. Thanks already! (I don't know what to flair my post)
/r/django
https://redd.it/18930in
Reddit
From the django community on Reddit
Explore this post and more from the django community
PGVector operator does not exist: vector <#> numeric
I am using PGvector with Django. While I usually leverage the PGvector ORM functionality, this usecase requires a complex query which I am running in raw sql as shown below. https://gist.github.com/Thehi198/de053c5bc402046f6e36468642681cfb
I get the output shown below when running django, where pgvector does not seem to recognize a list. I have tried converting to a nparray, and explicitly defining a list. I have also run this query in my Postgres console successfully.
Stack
Supabase Postgres: 15.1.0.133
PGvector Postgres: 0.5.1: Running a HNSW index
Django: 4.2.7
OpenAI text-embedding-ada-002: 1536 dim
https://preview.redd.it/9fzeyeogix3c1.png?width=891&format=png&auto=webp&s=1de7f2a4924f4ce188dec9080a256570afd62c14
/r/django
https://redd.it/189agze
I am using PGvector with Django. While I usually leverage the PGvector ORM functionality, this usecase requires a complex query which I am running in raw sql as shown below. https://gist.github.com/Thehi198/de053c5bc402046f6e36468642681cfb
I get the output shown below when running django, where pgvector does not seem to recognize a list. I have tried converting to a nparray, and explicitly defining a list. I have also run this query in my Postgres console successfully.
Stack
Supabase Postgres: 15.1.0.133
PGvector Postgres: 0.5.1: Running a HNSW index
Django: 4.2.7
OpenAI text-embedding-ada-002: 1536 dim
https://preview.redd.it/9fzeyeogix3c1.png?width=891&format=png&auto=webp&s=1de7f2a4924f4ce188dec9080a256570afd62c14
/r/django
https://redd.it/189agze
Gist
Using PGvector and rawsql for simularity search.
Using PGvector and rawsql for simularity search. GitHub Gist: instantly share code, notes, and snippets.
DRF - Why is CSRF token cookie not being set, disappears on page reload, and unable to get cookie?
I'm working on a Django / DFR + SvelteKit project and have been struggling for several days on this :(
I am trying to use Django's session-based auth system and csrf tokens which are stored in cookies.
Problems:
1. When the page first loads, there is no csrf token in the cookies, so for testing purposes I added a button to request one from the server. This does add the cookies to the page.
2. After the csrf token cookie is set, if I refresh the page, the cookie disappears and I have to click the "set csrf cookie" again... No clue why this is happening and have not been able to resolve it..
3. When I make the POST request, the csrf token logged out as undefined - and then the csrf cookie disappears - beyond frustrating and don't understand why this is happening.
4. When I make the request without any csrf token, essentially removing the `'X-CSRFToken': csrfToken` header in the request, the Django DRF view still accepts the post... when I explicitly set `authentication_classes = [SessionAuthentication\]` which should only accept POST requests that have valid csrfs....
Looking for any help that I can get.
Github link: https://github.com/SoRobby/DjangoSvelte/tree/main
Run django on port `8054`
​
REST and CORS Settings:
/r/django
https://redd.it/189d91t
I'm working on a Django / DFR + SvelteKit project and have been struggling for several days on this :(
I am trying to use Django's session-based auth system and csrf tokens which are stored in cookies.
Problems:
1. When the page first loads, there is no csrf token in the cookies, so for testing purposes I added a button to request one from the server. This does add the cookies to the page.
2. After the csrf token cookie is set, if I refresh the page, the cookie disappears and I have to click the "set csrf cookie" again... No clue why this is happening and have not been able to resolve it..
3. When I make the POST request, the csrf token logged out as undefined - and then the csrf cookie disappears - beyond frustrating and don't understand why this is happening.
4. When I make the request without any csrf token, essentially removing the `'X-CSRFToken': csrfToken` header in the request, the Django DRF view still accepts the post... when I explicitly set `authentication_classes = [SessionAuthentication\]` which should only accept POST requests that have valid csrfs....
Looking for any help that I can get.
Github link: https://github.com/SoRobby/DjangoSvelte/tree/main
Run django on port `8054`
​
REST and CORS Settings:
/r/django
https://redd.it/189d91t
GitHub
GitHub - SoRobby/DjangoSvelte
Contribute to SoRobby/DjangoSvelte development by creating an account on GitHub.
Help with Auth Tokens from other APIs
Quick overview of what I'm trying to build: User clicks a link, does an Oauth for API 1 is redirected to an Oauth for API 2 and then that is the last interaction the user has. Afterwards a subscription service from API 1 sends information that a record in API 1 has updated. This triggers calling information from API 1 using it go get information from API 2 and then updating the record on API 1 with information gathered from API 2. I'm fairly new to development, but I have all of this working locally using Flask and session[\] variables to store the tokens and use them when re-authenticating and refreshing.
Now that I am getting ready to actually implement this in the real world and not just my local machine I'm not sure what I need to do in order to store these tokens since there will be no user after they authorize my application with both of the other API's and so I obviously can't get them to click authorize since they won't be actively going to a page when I need to call the APIs. Searching has lead to way too many different
/r/flask
https://redd.it/186sd5f
Quick overview of what I'm trying to build: User clicks a link, does an Oauth for API 1 is redirected to an Oauth for API 2 and then that is the last interaction the user has. Afterwards a subscription service from API 1 sends information that a record in API 1 has updated. This triggers calling information from API 1 using it go get information from API 2 and then updating the record on API 1 with information gathered from API 2. I'm fairly new to development, but I have all of this working locally using Flask and session[\] variables to store the tokens and use them when re-authenticating and refreshing.
Now that I am getting ready to actually implement this in the real world and not just my local machine I'm not sure what I need to do in order to store these tokens since there will be no user after they authorize my application with both of the other API's and so I obviously can't get them to click authorize since they won't be actively going to a page when I need to call the APIs. Searching has lead to way too many different
/r/flask
https://redd.it/186sd5f
Reddit
From the flask community on Reddit
Explore this post and more from the flask community
Sunday Daily Thread: What's everyone working on this week?
# Weekly Thread: What's Everyone Working On This Week? 🛠️
Hello /r/Python! It's time to share what you've been working on! Whether it's a work-in-progress, a completed masterpiece, or just a rough idea, let us know what you're up to!
## How it Works:
1. Show & Tell: Share your current projects, completed works, or future ideas.
2. Discuss: Get feedback, find collaborators, or just chat about your project.
3. Inspire: Your project might inspire someone else, just as you might get inspired here.
## Guidelines:
Feel free to include as many details as you'd like. Code snippets, screenshots, and links are all welcome.
Whether it's your job, your hobby, or your passion project, all Python-related work is welcome here.
## Example Shares:
1. Machine Learning Model: Working on a ML model to predict stock prices. Just cracked a 90% accuracy rate!
2. Web Scraping: Built a script to scrape and analyze news articles. It's helped me understand media bias better.
3. Automation: Automated my home lighting with Python and Raspberry Pi. My life has never been easier!
Let's build and grow together! Share your journey and learn from others. Happy coding! 🌟
/r/Python
https://redd.it/189go42
# Weekly Thread: What's Everyone Working On This Week? 🛠️
Hello /r/Python! It's time to share what you've been working on! Whether it's a work-in-progress, a completed masterpiece, or just a rough idea, let us know what you're up to!
## How it Works:
1. Show & Tell: Share your current projects, completed works, or future ideas.
2. Discuss: Get feedback, find collaborators, or just chat about your project.
3. Inspire: Your project might inspire someone else, just as you might get inspired here.
## Guidelines:
Feel free to include as many details as you'd like. Code snippets, screenshots, and links are all welcome.
Whether it's your job, your hobby, or your passion project, all Python-related work is welcome here.
## Example Shares:
1. Machine Learning Model: Working on a ML model to predict stock prices. Just cracked a 90% accuracy rate!
2. Web Scraping: Built a script to scrape and analyze news articles. It's helped me understand media bias better.
3. Automation: Automated my home lighting with Python and Raspberry Pi. My life has never been easier!
Let's build and grow together! Share your journey and learn from others. Happy coding! 🌟
/r/Python
https://redd.it/189go42
Reddit
From the Python community on Reddit
Explore this post and more from the Python community
My first large scraping website built using Django
14 months I decided to learn programming. After 10 years as a nurse I needed a change. 3 months ago I built my wife a ecommerce website using Django and learned a ton. Today I launched my first large scraping website using Selenium and BS4. I used redis, celery, and postgres for this project. I use the Appliku SaaS to aide in easy deployment, a Hetzner server, and S3 bucket and CDN for images. I know very little JavaScript so I bought the HTML template off themeforest for like $12. I then manipulated the HTML and inserted the Django portions. I also use HTMX to decrease page reloads. HTMX is used mostly when submitting forms. I had to learn Docker due to needing a customized Dockerfile for selenium. At first I was using Playwright, but could not figure out how to get Playwright to work with the Dockerfile, so I switched to Selenium. One thing I noticed on my ecomm website was the large amount of bots that would sign up to site and send messages through contact form so I added ReCaptcha to help prevent this. I would suggest adding ReCaptcha as it's fairly easy to implement. I built
/r/django
https://redd.it/189e1xh
14 months I decided to learn programming. After 10 years as a nurse I needed a change. 3 months ago I built my wife a ecommerce website using Django and learned a ton. Today I launched my first large scraping website using Selenium and BS4. I used redis, celery, and postgres for this project. I use the Appliku SaaS to aide in easy deployment, a Hetzner server, and S3 bucket and CDN for images. I know very little JavaScript so I bought the HTML template off themeforest for like $12. I then manipulated the HTML and inserted the Django portions. I also use HTMX to decrease page reloads. HTMX is used mostly when submitting forms. I had to learn Docker due to needing a customized Dockerfile for selenium. At first I was using Playwright, but could not figure out how to get Playwright to work with the Dockerfile, so I switched to Selenium. One thing I noticed on my ecomm website was the large amount of bots that would sign up to site and send messages through contact form so I added ReCaptcha to help prevent this. I would suggest adding ReCaptcha as it's fairly easy to implement. I built
/r/django
https://redd.it/189e1xh
Reddit
From the django community on Reddit: My first large scraping website built using Django
Explore this post and more from the django community
Just found a library for Rust-style errors in Python
Was dreading having to do try/except for a bunch of stuff and found this Rust-style errors lib: https://github.com/rustedpy/result/
Anyone else converted?
/r/Python
https://redd.it/1897m0y
Was dreading having to do try/except for a bunch of stuff and found this Rust-style errors lib: https://github.com/rustedpy/result/
Anyone else converted?
/r/Python
https://redd.it/1897m0y
GitHub
GitHub - rustedpy/result: NOT MAINTAINED - A simple Rust like Result type for Python 3. Fully type annotated.
NOT MAINTAINED - A simple Rust like Result type for Python 3. Fully type annotated. - rustedpy/result
Sending mail via flask
I am trying to send mail using flask but i keep getting this error
(550, b'User hello@mymail.com has exceeded its 24-hour sending limit. Messages to 5 recipients out of 5 allowed have been sent. Relay quota will reset in 6.47 hours.', 'hello@mymail.com')
Here is my code
app.config"MAIL_SERVER" = "smtp.office365.com"
app.config"MAIL_PORT" = 587
app.config"START_TLS" = False
def sendemailverification(name, email, subid):
"""sending email verification""" expires = datetime.timedelta(minutes=30000) token = createaccesstoken(identity=str(subid), expiresdelta=expires)
msg = Message(
subject=PROJECTNAME, sender=app.config"MAIL_USERNAME", recipients=email
)
msg.html = rendertemplate(
"email-verification.html",
link=REACTROUTE + "/subscriber-changes?token=" + token + "&email=" + email,
email=email,
name=name,
websitename=PROJECTNAME,
reactroute=REACTROUTE,
)
mail.send(msg)
message = MIMEMultipart() message'From' = app.config"MAIL_USERNAME" message'To' = email message'Subject' = "View Changes" message.attach(MIMEText("body of mail", 'plain'))
Connect to the SMTP server
with smtplib.SMTP('smtpout.secureserver.net', 587) as server: server.starttls()
Log in to the server
server.login(app.config"MAIL_USERNAME", app.config"MAIL_PASSWORD")
/r/flask
https://redd.it/186ky1h
I am trying to send mail using flask but i keep getting this error
(550, b'User hello@mymail.com has exceeded its 24-hour sending limit. Messages to 5 recipients out of 5 allowed have been sent. Relay quota will reset in 6.47 hours.', 'hello@mymail.com')
Here is my code
app.config"MAIL_SERVER" = "smtp.office365.com"
app.config"MAIL_PORT" = 587
app.config"START_TLS" = False
def sendemailverification(name, email, subid):
"""sending email verification""" expires = datetime.timedelta(minutes=30000) token = createaccesstoken(identity=str(subid), expiresdelta=expires)
msg = Message(
subject=PROJECTNAME, sender=app.config"MAIL_USERNAME", recipients=email
)
msg.html = rendertemplate(
"email-verification.html",
link=REACTROUTE + "/subscriber-changes?token=" + token + "&email=" + email,
email=email,
name=name,
websitename=PROJECTNAME,
reactroute=REACTROUTE,
)
mail.send(msg)
message = MIMEMultipart() message'From' = app.config"MAIL_USERNAME" message'To' = email message'Subject' = "View Changes" message.attach(MIMEText("body of mail", 'plain'))
Connect to the SMTP server
with smtplib.SMTP('smtpout.secureserver.net', 587) as server: server.starttls()
Log in to the server
server.login(app.config"MAIL_USERNAME", app.config"MAIL_PASSWORD")
/r/flask
https://redd.it/186ky1h
Reddit
From the flask community on Reddit
Explore this post and more from the flask community