<commit_before>package controllers

import (
	"fmt"

	"github.com/kataras/iris"
	"gopkg.in/redis.v4"
)

type IndexController struct {
	redis *redis.Client
}

type Response struct {
	Result  bool   `json:"result"`
	Short   string `json:"short"`
	Message string `json:"message"`
}

func init() {
	client := redis.NewClient(&redis.Options{
		Addr:     "localhost:6379",
		Password: "", // no password set
		DB:       0,  // use default DB
	})

	pong, err := client.Ping().Result()
	fmt.Println(pong, err)
}

func (c *IndexController) IndexHandler(ctx *iris.Context) {
	if err := ctx.Render("index.html", nil); err != nil {
		fmt.Println(err.Error())
		panic(err)
	}
}

func (c *IndexController) GetShortHandler(ctx *iris.Context) {
}

func (c *IndexController) ShortURLHandler(ctx *iris.Context) {
	url := ctx.FormValue("url")
	resp := new(Response)

	if string(url) == "" {
		resp.Result = false
		resp.Message = "Please input URL first..."
	}

	if err := ctx.JSON(iris.StatusOK, resp); err != nil {
		fmt.Println(err.Error())
		panic(err)
	}
}
<commit_msg>Render JSON response<commit_after>package controllers

import (
	"fmt"

	"github.com/kataras/iris"
	"gopkg.in/redis.v4"
)

type IndexController struct {
	redis *redis.Client
}

type Response struct {
	Result  bool   `json:"result"`
	Short   string `json:"short"`
	Message string `json:"message"`
}

func init() {
	client := redis.NewClient(&redis.Options{
		Addr:     "localhost:6379",
		Password: "", // no password set
		DB:       0,  // use default DB
	})

	pong, err := client.Ping().Result()
	fmt.Println(pong, err)
}

func (c *IndexController) IndexHandler(ctx *iris.Context) {
	if err := ctx.Render("index.html", nil); err != nil {
		fmt.Println(err.Error())
		panic(err)
	}
}

func (c *IndexController) GetShortHandler(ctx *iris.Context) {
}

func (c *IndexController) ShortURLHandler(ctx *iris.Context) {
	url := ctx.FormValue("url")
	resp := new(Response)

	if string(url) == "" {
		resp.Result = false
		resp.Message = "Please input URL first..."

		ctx.JSON(iris.StatusOK, resp)
		return
	}

	fmt.Println("Input URL is:" + string(url))
}

{'fraction_non_alphanumeric': 0.1643705463182898, 'fraction_numerical': 0.005700712589073635, 'mean_word_length': 3.808219178082192, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '737503', 'n_tokens_mistral': 808, 'n_tokens_neox': 774, 'n_words': 175}