The Playlist Search Server allows clients to search for songs in a collection of playlists. Clients send a JSON payload containing the playlists, playlist name, search category (e.g., "title", "artist", "genre"), and search term. The server searches the specified playlist and returns a string response indicating whether a match was found or not.
-
-
- Python 3.7+
- ZeroMQ library (
pyzmq
)
-
- Clone the Repository:
git clone https://github.com/tjnorred/CS361-A.git
- Change directory:
cd CS361-A
- (Optional) Create virtual environment:
python -m venv venv
- (Optional) Activate virtual environment:
- Linux/Mac:
source venv/bin/activate
- Windows:
venv\Scripts\activate
- Install requirements:
pip install -r requirements.txt
orpip install pyzmq
- Clone the Repository:
-
-
You can start the server with the default port (5555) or specify a custom port using the -p or --port argument.
-
python server.py
-
python server.py -p 8080
or
python server.py --port 8080
-
-
context = zmq.Context() socket = context.socket(zmq.REQ) socket.connect("tcp://localhost:5555") # change the port number to match the server
-
# Example payload data = { "playlists": {"Running Mood": [ {"title": "Where You Are", "artist": "John Summit", "genre": "Electronic"}, {"title": "Summer", "artist": "Calvin Harris", "genre": "Electronic"}, {"title": "Running Up That Hill (A Deal With God)", "artist": "Kate Bush", "genre": "Synth-Pop"} ]}, "playlist_name": "Running Mood", "search_category": "artist", "search_term": "John Summit" } socket.send_json(data)
-
socket.recv_string()
- Logs all activities to
server.log
. - File contains timestamps, client IPs, received requests, sent responses, and any errors that occurred.
-
Tests are under the
/tests
directory -
Run the unit tests:
python -m unittest tests/testPlaylistSearch.py