<commit_before>package handlers

import (
	"net/http"
)

const WELCOME_HTML = `
<html>
  <head>
    <title>Straitjacket</title>
  </head>
  <body>
    <h1>Welcome to Straitjacket</h1>
    <form method="post" action="/execute">
				<dl>
						<dt>source:</dt>
						<dd><textarea name="source" rows=8 cols=50></textarea></dd>
						<dt>stdin:</dt>
						<dd><textarea name="stdin" rows=8 cols=50></textarea></dd>
						<dt>language:</dt>
						<dd>
								<select name="language">
										<option value="javascript">JavaScript</option>
										<option value="c#">C#</option>
										<option value="ruby">Ruby</option>
								</select>
						</dd>
				</dl>
				<input type="submit"/>
		</form>
  </body>
</html>
`

func (ctx *Context) IndexHandler(res http.ResponseWriter, req *http.Request) {
	res.Header().Set("Content-Type", "text/html")
	_, err := res.Write([]byte(WELCOME_HTML))
	if err != nil {
		panic(err)
	}
}<commit_msg>Dynamic Language Options on Index Page<commit_after>package handlers

import (
	"html/template"
	"net/http"
	"straitjacket/engine"
)

type options struct {
	Languages []*engine.Language
}

const WELCOME_HTML = `
<html>
  <head>
    <title>Straitjacket</title>
  </head>
  <body>
    <h1>Welcome to Straitjacket</h1>
    <form method="post" action="/execute">
				<dl>
						<dt>source:</dt>
						<dd><textarea name="source" rows=8 cols=50></textarea></dd>
						<dt>stdin:</dt>
						<dd><textarea name="stdin" rows=8 cols=50></textarea></dd>
						<dt>language:</dt>
						<dd>
								<select name="language">
									{{range .Languages}}
											<option value="{{.Name}}">{{.VisibleName}}</option>
									{{end}}
								</select>
						</dd>
				</dl>
				<input type="submit"/>
		</form>
  </body>
</html>
`

func (ctx *Context) IndexHandler(res http.ResponseWriter, req *http.Request) {
	opts := &options{
		Languages: ctx.Engine.Languages(),
	}
	tmpl, err := template.New("index").Parse(WELCOME_HTML)
	if err != nil {
		panic(err)
	}
	res.Header().Set("Content-Type", "text/html")
	err = tmpl.Execute(res, opts)
	if err != nil {
		panic(err)
	}
}
{'fraction_non_alphanumeric': 0.19456366237482117, 'fraction_numerical': 0.007629947544110634, 'mean_word_length': 3.0580270793036752, 'pattern_counts': {'":': 0, '<': 77, '<?xml version=': 0, '>': 77, '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': '2923719', 'n_tokens_mistral': 959, 'n_tokens_neox': 762, 'n_words': 145}