This Flask application demonstrates the functionalities of an audio server.
In the top-level directory:
$ python run.py
Pull down the source code from this GitLab repository:
$ git clone https://github.com/Vignesh9395/AudioServer.git```
Create a new virtual environment:
$ cd AudioServer
$ python3 -m venv venv
Activate the virtual environment:
$ source venv/bin/activate
Install the python packages in requirements.txt:
(venv) $ pip install -r requirements.txt
Run development server to serve the Flask application:
(venv) $ python run.py
Navigate to 'http://localhost:9935/audioFileType/audioFileID' to use the endpoint!
create, read, upload, and delete endpoints for an audio file as defined below:
The request will have the following fields:
- audioFileType – mandatory, one of the 3 audio types possible
- audioFileMetadata – mandatory, dictionary, contains the metadata for one of the three audio files (song, podcast, audiobook)
- The route will be in the following format: “audioFileType/audioFileID”
- The route be in the following format: “audioFileType/audioFileID”
- The request body will be the same as the upload
- The route “audioFileType/audioFileID” will return the specific audio file
- The route “audioFileType” will return all the audio files of that type
Audio file type can be one of the following:
- Song
- Podcast
- Audiobook
- ID – (mandatory, integer, unique)
- Name of the song – (mandatory, string, cannot be larger than 100 characters)
- Duration in number of seconds – (mandatory, integer, positive)
- Uploaded time – (mandatory, Datetime, cannot be in the past)
- ID – (mandatory, integer, unique)
- Name of the podcast – (mandatory, string, cannot be larger than 100 characters)
- Duration in number of seconds – (mandatory, integer, positive)
- Uploaded time – (mandatory, Datetime, cannot be in the past)
- Host – (mandatory, string, cannot be larger than 100 characters)
- Participants – (optional, list of strings, each string cannot be larger than 100 characters, maximum of 10 participants possible)
- ID – (mandatory, integer, unique)
- Title of the audiobook – (mandatory, string, cannot be larger than 100 characters)
- Author of the title (mandatory, string, cannot be larger than 100 characters)
- Narrator - (mandatory, string, cannot be larger than 100 characters)
- Duration in number of seconds – (mandatory, integer, positive)
- Uploaded time – (mandatory, Datetime, cannot be in the past)
- Flask: micro-framework for web application development
- pytest: framework for testing Python projects
- SQLAlchemy - ORM (Object Relational Mapper)
This application is written using Python 3+.
To run the tests:
(venv) $ cd tests/create
(venv) $ python -m pytest -v
(venv) $ cd tests/read
(venv) $ python -m pytest -v
(venv) $ cd tests/update
(venv) $ python -m pytest -v
(venv) $ cd tests/delete
(venv) $ python -m pytest -v