better if manipulated image restored to variable
This commit is contained in:
parent
f86969ebc0
commit
008f516cff
14
main.py
14
main.py
@ -37,10 +37,14 @@ def add_textimg(text, code):
|
|||||||
|
|
||||||
img.save(path)
|
img.save(path)
|
||||||
img.close()
|
img.close()
|
||||||
|
|
||||||
|
return open(f"images/output/pos-{str(code)}.jpg", "rb").read()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("Failed to add image")
|
print("Failed to add image")
|
||||||
print(str(e))
|
print(str(e))
|
||||||
|
|
||||||
|
return None
|
||||||
|
|
||||||
@app.route('/hello', methods=['GET'])
|
@app.route('/hello', methods=['GET'])
|
||||||
def hello():
|
def hello():
|
||||||
return "Hello"
|
return "Hello"
|
||||||
@ -72,7 +76,7 @@ def send_email():
|
|||||||
mail_host = os.environ.get("HOST") if os.environ.get("HOST") is not None else "smtp.gmail.com"
|
mail_host = os.environ.get("HOST") if os.environ.get("HOST") is not None else "smtp.gmail.com"
|
||||||
mail_port = 465
|
mail_port = 465
|
||||||
|
|
||||||
if mail_sender is None and mail_password is None:
|
if mail_sender is None or mail_password is None:
|
||||||
return jsonify({
|
return jsonify({
|
||||||
"status": 400,
|
"status": 400,
|
||||||
"error": "Bro did you forget to add the sender email and email password variables in the .env file?"
|
"error": "Bro did you forget to add the sender email and email password variables in the .env file?"
|
||||||
@ -88,8 +92,9 @@ def send_email():
|
|||||||
randis = random.randint(1000, 9999)
|
randis = random.randint(1000, 9999)
|
||||||
|
|
||||||
# message variable
|
# message variable
|
||||||
subject = "confirm your account"
|
subject = "Confirm your account"
|
||||||
msg = "Here's your email confirmation"
|
msg = """Here's your email confirmation code
|
||||||
|
if you're not the one doing this just ignore it"""
|
||||||
|
|
||||||
zmail = MIMEMultipart()
|
zmail = MIMEMultipart()
|
||||||
zmail['From'] = mail_sender
|
zmail['From'] = mail_sender
|
||||||
@ -100,8 +105,7 @@ def send_email():
|
|||||||
zmail.attach(MIMEText(msg, 'plain'))
|
zmail.attach(MIMEText(msg, 'plain'))
|
||||||
|
|
||||||
# attach picure
|
# attach picure
|
||||||
add_textimg("Your verification code is", str(randis))
|
pict = add_textimg("Your verification code is", str(randis))
|
||||||
pict = open(f"images/output/pos-{str(randis)}.jpg", "rb").read()
|
|
||||||
zmail.attach(MIMEImage(pict, name="black-man-wearing-suit.jpg"))
|
zmail.attach(MIMEImage(pict, name="black-man-wearing-suit.jpg"))
|
||||||
|
|
||||||
# creating context
|
# creating context
|
||||||
|
Loading…
x
Reference in New Issue
Block a user