<commit_before>package com.deseteral.oudjo;

import com.google.gson.Gson;

import static spark.Spark.*;
import static spark.SparkBase.stop;

public class WebService {

    private int port;
    private Gson gson;

    private boolean isRunning;

    public WebService(int port) {

        this.isRunning = false;

        this.port = port;
        port(port);

        this.gson = OudjoApp.createGson();
    }

    public void initialize() {

        isRunning = true;

        get("/version", (req, res) -> gson.toJson(OudjoApp.VERSION));

        // Player
        get("/player/play", (req, res) -> {
            OudjoApp.player.play();
            return "";
        });

        get("/player/pause", (req, res) -> {
            OudjoApp.player.pause();
            return "";
        });

        get("/player/stop", (req, res) -> {
            OudjoApp.player.stop();
            return "";
        });

        get("/player/next", (req, res) -> {
            OudjoApp.player.next();
            return "";
        });

        get("/player/previous", (req, res) -> {
            OudjoApp.player.previous();
            return "";
        });
    }

    public void stopWebService() {<commit_msg>Added database route (get song by ID)<commit_after>package com.deseteral.oudjo;

import com.google.gson.Gson;

import static spark.Spark.*;
import static spark.SparkBase.stop;

public class WebService {

    private int port;
    private Gson gson;

    private boolean isRunning;

    public WebService(int port) {

        this.isRunning = false;

        this.port = port;
        port(port);

        this.gson = OudjoApp.createGson();
    }

    public void initialize() {

        isRunning = true;

        get("/version", (req, res) -> gson.toJson(OudjoApp.VERSION));

        // Player
        get("/player/play", (req, res) -> {
            OudjoApp.player.play();
            return "";
        });

        get("/player/pause", (req, res) -> {
            OudjoApp.player.pause();
            return "";
        });

        get("/player/stop", (req, res) -> {
            OudjoApp.player.stop();
            return "";
        });

        get("/player/next", (req, res) -> {
            OudjoApp.player.next();
            return "";
        });

        get("/player/previous", (req, res) -> {
            OudjoApp.player.previous();
            return "";
        });

        // Database
        get("/song/:id", (req, res) -> {
            int id = Integer.parseInt(req.params(":id"));
            Song song = OudjoApp.database.getSongById(id);
            return gson.toJson(song);
        });
    }

    public void stopWebService() {
{'fraction_non_alphanumeric': 0.15254237288135594, 'fraction_numerical': 0.0, 'mean_word_length': 1.6613226452905812, 'pattern_counts': {'":': 1, '<': 3, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1079514', 'n_tokens_mistral': 812, 'n_tokens_neox': 778, 'n_words': 158}