Developing a RESTAPI using FastAPI that will send an email when someone registers themselves
git clone [email protected]:PritomKarmokar/SenderAPI.git
cd SenderAPI
Ensure you have Python and pip installed on your machine.
- Create a virtual environment:
python -m venv venv
- Activate the virtual environment:
- On Windows:
venv\Scripts\activate
- On Unix or macOS:
source venv/bin/activate
- On Windows:
- Install dependencies:
pip install -r requirements.txt
- Run the FastAPI app:
uvicorn code.main:app --reload
Ensure you have Docker and docker-compose installed on your machine.
- Build and run the Docker containers:
docker compose up --build
Access the app at http://localhost:8000
Access API documentation:
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
-
Configure the OAuth consent screen
- set the
User type
to External
- set the
-
Finally store the 'credentials.json' in
code/api_credentials
directory
When a user registers through the API, a welcome email will be sent using the Gmail API. The endpoint for registration is:
- POST /register: This endpoint takes the user's firstname, lastname (optional) and email address and saves it to the database, then sends a welcome email using Gmail API.