<commit_before>import java.util.HashMap;
import java.util.ArrayList;

import spark.ModelAndView;
import spark.template.velocity.VelocityTemplateEngine;
import static spark.Spark.*;

public class App {
    public static void main(String[] args) {
        staticFileLocation("/public");
        String layout = "templates/layout.vtl";

        get("/", (request, response) -> {
          HashMap<String,Object>model = new HashMap<String, Object>();
          model.put("definitions", request.session().attribute("definitions"));
          model.put("template", "templates/index.vtl");
          return new ModelAndView(model, layout);
        }, new VelocityTemplateEngine());

        get("/definitions", (request, response) -> {
          HashMap<String, Object> model = new HashMap<String, Object>();
          model.put("definitions", Definition.all());
          model.put("template", "templates/definitions.vtl");
          return new ModelAndView(model, layout);
          }, new VelocityTemplateEngine());

        get("definitions/new", (request, response) -> {
          HashMap<String, Object> model = new HashMap<String, Object>();
          model.put("template", "templates/definition-form.vtl");
          return new ModelAndView(model, layout);
          }, new VelocityTemplateEngine());

        post("/definitions", (request,response) -> {
          HashMap<String, Object>model = new HashMap<String, Object>();
          Word word = Word.find(Integer.parseInt(request.queryParams("wordId")));
          String description = request.queryParams("description");
          Definition newDefinition = new Definition(description);
          word.addDefinition(newDefinition);
          model.put("word", word);
          model.put("template", "templates/word.vtl");
          return new ModelAndView(model, layout);
        }, new VelocityTemplateEngine());

        //RESTful ARCHITECTURE
        //Use POST to create something on the server
        //Use GET to retrieve something from the server
        //Use PUT to change or update something on the server
        //Use DELETE to remove or delete something on the server
        //Keep URLs intuitive
        //Each request from client contains all info necessary for that request

        //ROUTES: Home Page

        // get("/", (request, response) -> {
        //     HashMap<String, Object> model = new HashMap<String, Object>();

        //     model.put("template", "templates/index.vtl");
        //     return new ModelAndView(model, layout);
        // }, new VelocityTemplateEngine());

        //ROUTES: Identification of Resources

        //ROUTES: Changing Resources

    }<commit_msg>add post method for words<commit_after>import java.util.HashMap;
import java.util.ArrayList;

import spark.ModelAndView;
import spark.template.velocity.VelocityTemplateEngine;
import static spark.Spark.*;

public class App {
    public static void main(String[] args) {
      staticFileLocation("/public");
      String layout = "templates/layout.vtl";

      get("/", (request, response) -> {
        HashMap<String,Object>model = new HashMap<String, Object>();
        model.put("definitions", request.session().attribute("definitions"));
        model.put("template", "templates/index.vtl");
        return new ModelAndView(model, layout);
      }, new VelocityTemplateEngine());

      get("/definitions", (request, response) -> {
        HashMap<String, Object> model = new HashMap<String, Object>();
        model.put("definitions", Definition.all());
        model.put("template", "templates/definitions.vtl");
        return new ModelAndView(model, layout);
        }, new VelocityTemplateEngine());

      get("definitions/new", (request, response) -> {
        HashMap<String, Object> model = new HashMap<String, Object>();
        model.put("template", "templates/definition-form.vtl");
        return new ModelAndView(model, layout);
        }, new VelocityTemplateEngine());

      post("/definitions", (request,response) -> {
        HashMap<String, Object>model = new HashMap<String, Object>();
        Word word = Word.find(Integer.parseInt(request.queryParams("wordId")));
        String description = request.queryParams("description");
        Definition newDefinition = new Definition(description);
        word.addDefinition(newDefinition);
        model.put("word", word);
        model.put("template", "templates/word.vtl");
        return new ModelAndView(model, layout);
      }, new VelocityTemplateEngine());

      get("/definitions/:id", (request, response) -> {
        HashMap<String, Object> model = new HashMap<String, Object>();
        Definition definition = Definition.find(Integer.parseInt(request.params(":id")));
        model.put("definition", definition);
        model.put("template", "templates/definition.vtl");
        return new ModelAndView(model, layout);
      }, new VelocityTemplateEngine());

      get("/words", (request, response) -> {
        HashMap<String, Object> model = new HashMap<String, Object>();
        model.put("words", Word.all());
        model.put("template", "templates/words.vtl");
        return new ModelAndView(model, layout);
      }, new VelocityTemplateEngine());

      get("words/new", (request, response) -> {
        HashMap<String, Object> model = new HashMap<String, Object>();
        model.put("template", "templates/word-form.vtl");
        return new ModelAndView(model, layout);
      }, new VelocityTemplateEngine());

      post("/words", (request,response) -> {
        HashMap<String, Object>model = new HashMap<String, Object>();
        String name = request.queryParams("name");
        Word newWord = new Word(name);
        model.put("word", newWord);
        model.put("template", "templates/success.vtl");
        return new ModelAndView(model, layout);
      }, new VelocityTemplateEngine());

        //RESTful ARCHITECTURE
        //Use POST to create something on the server
        //Use GET to retrieve something from the server
        //Use PUT to change or update something on the server
        //Use DELETE to remove or delete something on the server
        //Keep URLs intuitive
        //Each request from client contains all info necessary for that request

        //ROUTES: Home Page

        // get("/", (request, response) -> {
        //     HashMap<String, Object> model = new HashMap<String, Object>();

        //     model.put("template", "templates/index.vtl");
        //     return new ModelAndView(model, layout);
        // }, new VelocityTemplateEngine());

        //ROUTES: Identification of Resources

        //ROUTES: Changing Resources

    }
{'fraction_non_alphanumeric': 0.13602166716822148, 'fraction_numerical': 0.0, 'mean_word_length': 2.8735431235431235, 'pattern_counts': {'":': 1, '<': 31, '<?xml version=': 0, '>': 45, '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': '2935691', 'n_tokens_mistral': 1690, 'n_tokens_neox': 1671, 'n_words': 452}