This document provides instructions on how to set up and run the application.
Ensure you have the following installed on your system:
- Docker
- Python 3.11.5
- Docker Compose
- Make (for development)
To get a local copy of the code, clone the repository and navigate into the project directory:
git clone https://github.com/PradeepTammali/WebService.git
cd WebServicedocker compose up -dThe service will be accessible at http://localhost:5555
First, start the MySQL server:
docker compose up -d omdb-mysqlThen, run the application using one of the following commands:
SERVICE_DATABASE_USER=root SERVICE_DATABASE_PASSWORD=1234 SERVICE_DATABASE_HOST=localhost SERVICE_DATABASE_PORT=3308 SERVICE_DATABASE_NAME=omdb gunicorn -b :5555 run:app
or
SERVICE_DATABASE_USER=root SERVICE_DATABASE_PASSWORD=1234 SERVICE_DATABASE_HOST=localhost SERVICE_DATABASE_PORT=3308 SERVICE_DATABASE_NAME=omdb FLASK_APP=run.py FLASK_RUN_PORT=5555 flask run
The service will be accessible at http://localhost:5555
Ensure make is installed on your system for development purposes.
To install and run the application, use:
make all
To run the application
make run
The service will be accessible at http://localhost:5555
To run linting:
make lint
To run tests:
make test
Here's a summary of the endpoints:
Movie Endpoints (defined in omdb/routes/movie.py):
POST /movies/: Creates a new movie. The logic is implemented in themovie_createfunction.GET /movies/: Retrieves multiple movies. The logic is implemented in themovie_multiplefunction.GET /movies/<string:title>: Retrieves a single movie by its title. The logic is implemented in themovie_onefunction.POST /movies/<string:title>: Creates a new movie from a title. The logic is implemented in themovie_create_from_titlefunction.DELETE /movies/<int:movie_id>: Deletes a movie by its ID. The user must be verified to access this endpoint. The logic for deleting a movie is implemented in themovie_deletefunction.
Login Endpoints (defined in omdb/routes/login.py):
POST /login: Logs in a user. The logic is implemented in theuser_loginfunction.GET /login: Retrieves login information. The logic is implemented in theuser_loginfunction.GET /logout: Logs out a user. The logic is implemented in theuser_logoutfunction.POST /register: Registers a new user. The logic is implemented in theuser_registerfunction.GET /register: Retrieves registration information. The logic is implemented in theuser_registerfunction.GET /delete/<int:user_id>: Deletes a user by its ID. The logic is implemented in theuser_deletefunction.
Each of these endpoints is associated with a specific function in the views, which in turn uses a controller to interact with the data models. The controllers are defined in the omdb/controllers/ directory.