The backend has been divided into two parts : client_server and microservice.
Firstly, the microservice needs to be run (which will trigger the youtube_data_api every 10 seconds and the videos will be stored in the database) and then the client_server needs to be run will connect the apis with the postgresql database
A virtual environment needs to be created :
py -m venv env
.\env\Scripts\activate
Dependencies needs to be installed :
pip install -r requirements.txt
The variables.ini
file should be configured with the databse credentials and the youtube data api's developer key.
The following commands needs to be executed :
py createTable.py
---> To create the database table
py insertTable.py
---> To store the youtube api response in the databse periodically
A .env
file needs to be created with stores the SQLALCHEMY_DATABASE_URI
and the SCHEMA_NAME
For example,
SQLALCHEMY_DATABASE_URI ="postgresql://postgres:root@127.0.0.1:5432/postgres"
SCHEMA_NAME ="public"
Then the following command needs to be executed :
py run.py
---> To run the flask server
get()
--> To get the paginated response of the videos added in the database
The get() api is called by requesting response at http://127.0.0.1:5000/get/pageNumber
where pageNumber should be integer page no.s
Sample url : http://127.0.0.1:5000/get/2
search_video()
--> To get the search result from the database
The search_video() api is called by requesting response at http://127.0.0.1:5000/search/video/searchKey
where searchKey should be string input
Sample url : http://127.0.0.1:5000/search/video/virat$kohli