<commit_before>package gogoHTTP

import (
   "strings"
   "log"
    "flag"
    "net/http"
)

var dirFlag = flag.String("d",".","Specify directory to serve (default: /.)")
var portFlag = flag.String("p","8080","Specify directory to serve. (default: 8080)")

func Log(handler http.Handler) http.Handler {
    return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
        log.Printf("%s %s %s", r.RemoteAddr, r.Method, r.URL)
        handler.ServeHTTP(w, r)
    })
}

func listen(){
    log.Printf("Listening on port %s",*portFlag)
    log.Fatal(http.ListenAndServe(strings.Join([]string{":",*portFlag},""), Log(http.FileServer(http.Dir(*dirFlag)))))
}

func main() {
    // Simple static webserver:
    flag.Parse()
    listen()
}
<commit_msg>added request count and ctrl-c handling<commit_after>package main

import (
   "strings"
   "log"
   "flag"
   "net/http"
   "os/signal"
   "os"
)

var dirFlag = flag.String("d",".","Specify directory to serve (default: /.)")
var portFlag = flag.String("p","8080","Specify directory to serve. (default: 8080)")

var servecount int

func Log(handler http.Handler) http.Handler {
    return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
        servecount = servecount + 1
        log.Printf("%s %s %s", r.RemoteAddr, r.Method, r.URL)
        handler.ServeHTTP(w, r)
    })
}

func listen(){
    //listen for ctrl-c
    go func(){
        sigchan := make(chan os.Signal, 1)
        signal.Notify(sigchan, os.Interrupt)
        <-sigchan
        log.Printf("Served %d requests", servecount)
        log.Println("Terminating gogoHTTP, Goodbye!")
        os.Exit(0)
    }()
    log.Printf("Listening on port %s",*portFlag)
    log.Fatal(http.ListenAndServe(strings.Join([]string{":",*portFlag},""), Log(http.FileServer(http.Dir(*dirFlag)))))
}

func main() {
    // Simple static webserver:
    servecount = 0
    flag.Parse()
    listen()
}

{'fraction_non_alphanumeric': 0.1693674856246733, 'fraction_numerical': 0.010454783063251438, 'mean_word_length': 3.330316742081448, 'pattern_counts': {'":': 2, '<': 4, '<?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': '5582830', 'n_tokens_mistral': 673, 'n_tokens_neox': 662, 'n_words': 143}