- This project is about Flask based API services. Integration with Flask-restplus, Flask-Cors, Flask-Testing, Flask-SQLalchemy,and Flask-OAuth extensions.
-
Restful: Flask-restplus
-
SQL ORM: Flask-SQLalchemy
-
Testing: Flask-Testing
-
OAuth: Flask-OAuth
Install with pip:
$ pip install -r requirements.txt
.
|──────prequin_flask/
| |────__init__.py
| |────Configuration/
| | |────configreader.py
| | |────service.yml
| |────Scripts/
| | |────main.py
| | |────Constants/
| | | |────const.py
| | |────Services/
| | | |────__init__.py
| | | |────DatabaseConnection/
| | | | |────__init__.py
| | | | |────prequin_db_connection.py
| | | |────LoginRegister/
| | | | |────__init__.py
| | | | |────user_login.py
| | |────Utility
| | | |────Log
| | | | |────logger.py
| | | |────var
| |────README.md
| |────requirements.txt
| |────__root__.py
| |────unit_testing/
| | |────__init__.py
| | |────test_cal.py
| |────run_flasked_api.py
Objective: To develop RESTful APIs using that can be utilized by mobile and web applications. The applications will satisfy the following user stories:
● User should be able to login or sign up using his phone number (no OTP or verification code required). ● User can calculate simple algebraic calculations of two variables viz. x and y, for eg. x + y.
To run the project: Go to project directory and then run:
-
python3 run_flasked_app.py
OR
-
gunicorn run_flasked_app:app_wsgi --preload -b 0.0.0.0:8000
Create new docker image for the project
-
$
docker build -t <container_image_name> <destination_dir>
for e.g.docker built -t truckbook-docker-image ./
-
$
docker image
s # To check running docker images -
$
docker run -rm -it -d -p <port_of_choice>:5011 <container_image_name>
Database: Postgres (local)
Descriptions of APIs and endpoints:
- Sign-up with phone number and password on sign-up page
0.0.0.0:8000/signup
- GET Method to fetch result GET
0.0.0.0:8000/
- POST Method to calculate algebraic calculations (viz, add, subtract, multiply, divide) POST
0.0.0.0:8000/calculate
with JSON request body as
{ "operation": "add", "x": 20, "y": 30 }
- Test cases can be run :
python -m unittest /unit_testing/test_cal.py