Project created for implementing the task which is here
- Python
- Flask framework for API handling
- C++ in
movie_selector/choose_movies.cpp
used in computation.
- Build the file
movie_selector/choose_movies.cpp
. - Place the executable file in dir
movie_selector
. - Update path to this file in
utils.py
as varMOVIE_SELECTOR
.
- Create a virtual environment from
requirements.txt
. - Run
python mainhandler.py
. - By default, the server runs on
localhost:5000
, if no errors are encountered.
-
/
- Method :
GET
- Used to check if server is running.
- Method :
-
/api/get_profit_movies
- Method :
POST
- Returns data of chosen profitable movies.
- Method :
- Payload for
/api/get_profit_movies
{
"schedule" : [
{
"movie_name" : "Bala",
"start_date" : "8 Jan",
"end_date" : "28 Jan"
},
{
"movie_name" : "Rock",
"start_date" : "20 Jan",
"end_date" : "30 Jan"
},
{
"movie_name": "Brave",
"start_date": "2 Feb",
"end_date": "14 Feb"
},
{
"movie_name": "Race",
"start_date": "15 Feb",
"end_date": "28 Feb"
}
]
}
- Output for
/api/get_profit_movies
. - Returns
Success
when computation is completed with no internal errors. - Returns
Failure
when some internal error occurs.
{
"status": "Success",
"result": [
{
"movie_name": "Rock",
"start_date": "20 Jan",
"end_date": "30 Jan"
},
{
"movie_name": "Brave",
"start_date": "2 Feb",
"end_date": "14 Feb"
},
{
"movie_name": "Race",
"start_date": "15 Feb",
"end_date": "28 Feb"
}
]
}
{
"status": "Failed"
}
- APIs are tested using
Postman v7.25.0
. - Python scripts call
movie_selector/choose_movies.exe
(executable file generated after build in Step1) internally to generate results. - Communication between python scripts and cpp executable is done using file I/O.
- Input and Output file names in python scripts and cpp programs should be same.
- Executable paths if changed, should be updated in python scripts.
- PRs accepted on
master