Update docs

This commit is contained in:
Nomi Nonsense (Nonszy) 2023-09-09 11:02:21 +07:00
parent 7724ce0da3
commit 7720dedc97
2 changed files with 28 additions and 7 deletions

View File

@ -1,10 +1,31 @@
# 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
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)

View File

@ -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: