Below are the two API which can be tested using Postman
-
GET /users => For getting List of all the users.
-
POST /users => For adding a new user.
As the part of dynamic port setting the user can change FLASK_RUN_PORT(set to 5000) from .flaskenv file.
For database, MySQL database is used which is hosted on AWS RDS.
Library used for interacting with database is PyMySQL and interaction is done by procedure calls.
A user Table is created which is having all the details of the user.
GET /users route will get list of all the users
response format in status code 200: { "data": [ { "address": { "address_line_one": "something", "address_line_two": null, "city": "ahmn", "flat_number": "785", "pincode": "361001", "state": "Gujarat" }, "email": "leam@email.com", "mobile": "7778889898", "name": "leam", "user_id": 14 } ], "success": true }
POST /users route create a new user in database
For Validating the request data Cerberus library is used.
request_body: { "address": { "address_line_one": "something", "address_line_two":"optional", "city": "Ahmedabad", "flat_number": "785", "pincode": "361001", "state": "Gujarat" }, "email": "leam@email.com", "mobile": "7778889898", "name": "leam" }
response_body: { "address": { "address_line_one": "something", "address_line_two":"optional", "city": "Ahmedabad", "flat_number": "785", "pincode": "361001", "state": "Gujarat" }, "email": "leam@email.com", "mobile": "7778889898", "name": "leam", "user_id": 15 }
./procedures/create_user_table.sql
./procedures/insert_new_user.sql
./procedures/get_all_users.sql
./procedures/check_existing_email_mobile.sql
Deployed my flask app on AWS EC-2. The App is currently hosted on 13.235.51.69 (Public IP)
Used Gunicorn as a service for deployment and nginx as a webserver.
./gunicorn.service
./nginx.conf