fix dotenv
This commit is contained in:
parent
ead75deb5b
commit
d84122a39a
@ -7,6 +7,7 @@ Idk why i made this. A REST API that sends a one-time authentication code (a.k.a
|
|||||||
|
|
||||||
Packages required:
|
Packages required:
|
||||||
- flask
|
- flask
|
||||||
|
- python-dotenv
|
||||||
|
|
||||||
Setup:
|
Setup:
|
||||||
- Create a new `.env` file
|
- Create a new `.env` file
|
||||||
|
10
main.py
10
main.py
@ -2,6 +2,7 @@ import os
|
|||||||
import random
|
import random
|
||||||
import ssl
|
import ssl
|
||||||
import smtplib
|
import smtplib
|
||||||
|
from dotenv import load_dotenv
|
||||||
|
|
||||||
from flask import Flask, jsonify, request
|
from flask import Flask, jsonify, request
|
||||||
from PIL import Image, ImageDraw, ImageFont
|
from PIL import Image, ImageDraw, ImageFont
|
||||||
@ -10,6 +11,7 @@ from email.mime.multipart import MIMEMultipart
|
|||||||
from email.mime.text import MIMEText
|
from email.mime.text import MIMEText
|
||||||
from email.mime.image import MIMEImage
|
from email.mime.image import MIMEImage
|
||||||
|
|
||||||
|
load_dotenv()
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
|
|
||||||
INPUT_IMG_PATH = "images/main/shannon.jpg" # image path
|
INPUT_IMG_PATH = "images/main/shannon.jpg" # image path
|
||||||
@ -81,14 +83,14 @@ def send_email():
|
|||||||
# Create an .env file at the root of this project
|
# Create an .env file at the root of this project
|
||||||
# There are two values required here, EMAIL_SENDER and EMAIL_PASSWORD
|
# There are two values required here, EMAIL_SENDER and EMAIL_PASSWORD
|
||||||
# Or you can change the value here and in .env file
|
# Or you can change the value here and in .env file
|
||||||
mail_sender = os.environ.get("EMAIL_SENDER")
|
mail_sender = os.getenv("EMAIL_SENDER")
|
||||||
mail_password = os.environ.get("EMAIL_PASSWORD")
|
mail_password = os.getenv("EMAIL_PASSWORD")
|
||||||
mail_receiver = request.args.get('email')
|
mail_receiver = request.args.get('email')
|
||||||
|
|
||||||
# Everyone has a different email host service
|
# Everyone has a different email host service
|
||||||
# By default we use gmail to test our emails
|
# By default we use gmail to test our emails
|
||||||
mail_host = os.environ.get("HOST") if os.environ.get("HOST") is not None else "smtp.gmail.com"
|
mail_host = os.getenv("HOST") if os.getenv("HOST") is not None else "smtp.gmail.com"
|
||||||
mail_port = os.environ.get("PORT") if os.environ.get("PORT") is not None else 465
|
mail_port = os.getenv("PORT") if os.getenv("PORT") is not None else 465
|
||||||
|
|
||||||
if mail_sender is None or mail_password is None:
|
if mail_sender is None or mail_password is None:
|
||||||
return jsonify({
|
return jsonify({
|
||||||
|
Loading…
x
Reference in New Issue
Block a user