<commit_before>package staticfiles

import (
    "fmt"
    // "log"
    "net/http"
    "github.com/julienschmidt/httprouter"

    "path/filepath"
    "os"
    "strings"
    // "io/ioutil"

    "../views"
)

const StaticDirectories = "/static"


// STATICFILES

type Staticfile struct {
    Servedpath string
    Realpath string
}

func (file Staticfile) Serve(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
    fmt.Fprint(w, GetStaticfile(file.Realpath))
}

func GetStaticfile(path string) string {
    return views.GetTemplateContents(path)
}

func GetStaticfiles() []Staticfile {
    searchdir := "../app"
    staticfiles := []string{}
    staticstructs := []Staticfile{}
    filepath.Walk(searchdir, func(fp string, fi os.FileInfo, err error) error {<commit_msg>correct content-type for static files<commit_after>package staticfiles

import (
    "fmt"
    // "log"
    "net/http"
    "github.com/julienschmidt/httprouter"

    "path/filepath"
    "os"
    "strings"
    // "io/ioutil"

    "../views"
    "mime"
)

const StaticDirectories = "/static"


// STATICFILES

type Staticfile struct {
    Servedpath string
    Realpath string
}

func (file Staticfile) Serve(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
    filetype := strings.SplitAfter(file.Realpath, ".")
    mimetype := mime.TypeByExtension("." + filetype[len(filetype)-1])
    w.Header().Set("Content-Type", mimetype + ", charset=UTF-8")
    fmt.Fprint(w, GetStaticfile(file.Realpath))
}

func GetStaticfile(path string) string {
    return views.GetTemplateContents(path)
}

func GetStaticfiles() []Staticfile {
    searchdir := "../app"
    staticfiles := []string{}
    staticstructs := []Staticfile{}
    filepath.Walk(searchdir, func(fp string, fi os.FileInfo, err error) error {
{'fraction_non_alphanumeric': 0.13918390162101732, 'fraction_numerical': 0.0011179429849077697, 'mean_word_length': 3.4416873449131513, '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': '7469652', 'n_tokens_mistral': 607, 'n_tokens_neox': 593, 'n_words': 127}