<commit_before>package main

import (
	"log"
	"net"
	"net/http"
	"regexp"
	"strings"

	"swapgur/config"
	"swapgur/backend"
	"swapgur/frontend"
)

var categories = []string{
	"random",
	"art",
	"aww",
	"funny",
	"gifs",
	"nature",
	"nsfw",
	"sports",
}

func main() {
	http.HandleFunc("/", RootHandler)
	log.Println("Starting ListenAndServer")
	http.ListenAndServe(config.ListenAddr, nil)
}

func categoryValid(category string) bool {
	for i := range categories {
		if categories[i] == category {
			return true
		}
	}
	return false
}

func RootHandler(w http.ResponseWriter, r *http.Request) {
	status, receiving := bidnessLogic(r)
	w.WriteHeader(status)

	pd := frontend.NewPageData(receiving, categories...)
	if err := frontend.Output(w, pd); err != nil {
		log.Println(err)
	}
}

var welcome = `The rules are easy - give an image, receive an image from a<commit_msg>added defaults to the categories<commit_after>package main

import (
	"log"
	"net"
	"net/http"
	"regexp"
	"strings"

	"swapgur/config"
	"swapgur/backend"
	"swapgur/frontend"
)

var categories = []string{
	"random",
	"art",
	"aww",
	"funny",
	"gifs",
	"nature",
	"nsfw",
	"sports",
}

var categoryDefaults = []string{
	"http://i.imgur.com/vHWOYAU.gif", //random
	"http://i.imgur.com/D8CoAEd.jpg", //art
	"http://i.imgur.com/h2EiFHA.jpg", //aww
	"http://i.imgur.com/QnTc8BW.gif", //funny
	"http://i.imgur.com/QnTc8BW.gif", //gifs
	"http://i.imgur.com/Yavzdox.jpg", //nature
	"http://i.imgur.com/N8lL8H6.jpg", //nsfw
	"http://i.imgur.com/gUgkpTx.jpg", //sports
}

func main() {

	for i := range categoryDefaults {
		backend.Swap(categories[i], categoryDefaults[i])
	}

	http.HandleFunc("/", RootHandler)
	log.Println("Starting ListenAndServer")
	http.ListenAndServe(config.ListenAddr, nil)
}

func categoryValid(category string) bool {
	for i := range categories {
		if categories[i] == category {
			return true
		}
	}
	return false
}

func RootHandler(w http.ResponseWriter, r *http.Request) {
	status, receiving := bidnessLogic(r)
	w.WriteHeader(status)

	pd := frontend.NewPageData(receiving, categories...)
	if err := frontend.Output(w, pd); err != nil {
		log.Println(err)
	}
}

var welcome = `The rules are easy - give an image, receive an image from a
{'fraction_non_alphanumeric': 0.169438202247191, 'fraction_numerical': 0.003146067415730337, 'mean_word_length': 4.024830699774267, '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': '4676673', 'n_tokens_mistral': 907, 'n_tokens_neox': 873, 'n_words': 184}