<commit_before>package main

import (
	"flag"
	"github.com/SaviorPhoenix/http-server/cache"
	"github.com/SaviorPhoenix/http-server/data"
	"github.com/SaviorPhoenix/http-server/handles"
	"github.com/SaviorPhoenix/http-server/refresh"
	"log"
	"net/http"
)

type Options struct {
	port     *string
	useTls   *bool
	certPath *string
	certKey  *string
}

var Opts *Options

func init() {
	Opts = &Options{
		flag.String("port", "", "Bind port (Default 80 for HTTP, 443 for HTTPS)"),
		flag.Bool("use-tls", false, "Use SSL/TLS (https)"),
		flag.String("cert", "./cert.pem", "Path to a signed SSL/TLS certificate"),
		flag.String("cert-key", "./key.pem", "Path to the key associated with the signed SSL/TLS certificate"),
	}
	flag.Parse()

	//Set the default port depending on if we're serving HTTP or HTTPS
	if *Opts.useTls == true && *Opts.port == "" {
		*Opts.port = "443"
	} else if *Opts.useTls == false && *Opts.port == "" {
		*Opts.port = "80"
	}

	//Initialize the data-getter map for the documents
	data.InitGetters()

	//Register our path handles
	handles.Register()

	//We can't do much if we don't have a document cache, so panic
	// if we fail to get one
	if err := cache.InitCache("./docs/"); err != nil {
		panic(err)
	}

	if err := refresh.InitCacheWatch(cache.Docs); err != nil {
		panic(err)
	}

	if err := refresh.Watch.WatchCache(); err != nil {
		panic(err)
	}
}

func main() {
	if *Opts.useTls == true {
		log.Println("Accepting HTTPS on port:", *Opts.port)
		if err := http.ListenAndServeTLS(":"+*Opts.port, *Opts.certPath, *Opts.certKey, nil); err != nil {
			panic(err)
		}
	} else {
		log.Println("Accepting HTTP on port:", *Opts.port)
		if err := http.ListenAndServe(":"+*Opts.port, nil); err != nil {
			panic(err)
		}
	}
}
<commit_msg>Added -refresh flag for enabling/disable automatic document refreshing<commit_after>package main

import (
	"flag"
	"github.com/SaviorPhoenix/http-server/cache"
	"github.com/SaviorPhoenix/http-server/data"
	"github.com/SaviorPhoenix/http-server/handles"
	"github.com/SaviorPhoenix/http-server/refresh"
	"log"
	"net/http"
)

type Options struct {
	port     *string
	useTls   *bool
	certPath *string
	certKey  *string
	refresh  *bool
}

var Opts *Options

func init() {
	Opts = &Options{
		flag.String("port", "", "Bind port (Default 80 for HTTP, 443 for HTTPS)"),
		flag.Bool("use-tls", false, "Use SSL/TLS (https)"),
		flag.String("cert", "./cert.pem", "Path to a signed SSL/TLS certificate"),
		flag.String("cert-key", "./key.pem", "Path to the key associated with the signed SSL/TLS certificate"),
		flag.Bool("refresh", true, "Automatically refresh modified documents in ./docs"),
	}
	flag.Parse()

	//Set the default port depending on if we're serving HTTP or HTTPS
	if *Opts.useTls == true && *Opts.port == "" {
		*Opts.port = "443"
	} else if *Opts.useTls == false && *Opts.port == "" {
		*Opts.port = "80"
	}

	//Initialize the data-getter map for the documents
	data.InitGetters()

	//Register our path handles
	handles.Register()

	//We can't do much if we don't have a document cache, so panic
	// if we fail to get one
	if err := cache.InitCache("./docs/"); err != nil {
		panic(err)
	}

	if *Opts.refresh == true {
		if err := refresh.InitCacheWatch(cache.Docs); err != nil {
			panic(err)
		}
		if err := refresh.Watch.WatchCache(); err != nil {
			panic(err)
		}
	}
}

func main() {
	if *Opts.useTls == true {
		log.Println("Accepting HTTPS on port:", *Opts.port)
		if err := http.ListenAndServeTLS(":"+*Opts.port, *Opts.certPath, *Opts.certKey, nil); err != nil {
			panic(err)
		}
	} else {
		log.Println("Accepting HTTP on port:", *Opts.port)
		if err := http.ListenAndServe(":"+*Opts.port, nil); err != nil {
			panic(err)
		}
	}
}

{'fraction_non_alphanumeric': 0.16536282708389533, 'fraction_numerical': 0.005395198273536552, 'mean_word_length': 3.5834363411619283, 'pattern_counts': {'":': 4, '<': 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': '3887112', 'n_tokens_mistral': 1437, 'n_tokens_neox': 1372, 'n_words': 362}