From 7720dedc9777caa61f95998bf380c5ed12e24ceb Mon Sep 17 00:00:00 2001 From: norman-andrians Date: Sat, 9 Sep 2023 11:02:21 +0700 Subject: [PATCH] Update docs --- README.md | 29 +++++++++++++++++++++++++---- main.py | 6 +++--- 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 2c9f9cf..a889b6b 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,33 @@ # OTP with meme image -Leisure project. A REST API that sends a one-time authentication code (a.k.a OTP) but the code is in the text of a meme image. +Leisure project. A REST API that sends a one-time authentication code (a.k.a OTP) to email, but the code is in the text of a meme image. -## Summary +## Usage -If it works perfectly the result will be like this: +Setup: +- Create a new `.env` file +- Add your `EMAIL_SENDER` and `EMAIL_PASSWORD` in your `.env` file +- Create or use an API test app like Postman -![Example Outpus](./docs/example.png) +Usage: +- Run `main.py` +- Send a request to http://localhost:5000/send-otp with your `email` query as email recipient. E.g: http://localhost:5000/send-top?email=your@email.com. +- If successful then a response appears like this: + ```json + { + "email": { + "body": "Here's your email confirmation", + "receiver": "your.receiver@email.com", + "sender": "your.sender@email.com", + "subject": "confirm your account" + }, + "message": "Success sending email", + "status": 200 + } + ``` +- Now if you look at the recipient's email, it will be the image that was sent: + + ![Example Outpus](./docs/example.png) ## Why this meme? diff --git a/main.py b/main.py index 93ddf45..010a7b0 100644 --- a/main.py +++ b/main.py @@ -47,10 +47,10 @@ def hello(): @app.route('/send-otp', methods=['POST']) def send_email(): # Create an .env file at the root of this project - # There are two values required here, EMAIL_SENDER_2 and EMAIL_PASSWORD_2 + # There are two values required here, EMAIL_SENDER and EMAIL_PASSWORD # Or you can change the value here and in .env file - mail_sender = os.environ.get("EMAIL_SENDER_2") - mail_password = os.environ.get("EMAIL_PASSWORD_2") + mail_sender = os.environ.get("EMAIL_SENDER") + mail_password = os.environ.get("EMAIL_PASSWORD") mail_receiver = request.args.get('email') if mail_receiver is None: