<commit_before>package main

import (
	"log"
	"net/http"
	"os"

	"github.com/codequest-eu/burnafterreading"
	"github.com/codequest-eu/burnafterreading/authorizer"
	"github.com/codequest-eu/burnafterreading/storage"
)

func getStorage() (burnafterreading.Storage, error) {
	return storage.S3Storage(
		os.Getenv("AWS_ACCESS_KEY_ID"),
		os.Getenv("AWS_SECRET_ACCESS_KEY"),
		os.Getenv("AWS_REGION"),
		os.Getenv("AWS_BUCKET"),
	)
}

func getAuth() burnafterreading.Authorizer {
	return authorizer.BasicHTTPAuthorizer(os.Getenv("USER"), os.Getenv("PASS"))
}

func runServer() error {
	addr := os.Getenv("ADDR")
	log.Printf("Starting HTTP server bound to %q", addr)
	if os.Getenv("USE_SSL") == "" {
		return http.ListenAndServe(addr, nil)
	}
	return http.ListenAndServeTLS(addr, "cert.pem", "cert.key", nil)
}

func main() {
	storageEngine, err := getStorage()
	if err != nil {
		log.Fatalf("error initializing storage: %v", err)
	}
	http.Handle("/", &burnafterreading.Handler{
		Authorizer: getAuth(),
		Storage:    storageEngine,
	})
	log.Fatal(runServer())
}<commit_msg>Server to support local storage<commit_after>package main

import (
	"log"
	"net/http"
	"os"

	"github.com/codequest-eu/burnafterreading"
	"github.com/codequest-eu/burnafterreading/authorizer"
	"github.com/codequest-eu/burnafterreading/storage"
)

func getS3Storage() (burnafterreading.Storage, error) {
	return storage.S3Storage(
		os.Getenv("AWS_ACCESS_KEY_ID"),
		os.Getenv("AWS_SECRET_ACCESS_KEY"),
		os.Getenv("AWS_REGION"),
		os.Getenv("AWS_BUCKET"),
	)
}

func getFileStorage() (burnafterreading.Storage, error) {
	return storage.LocalFileStorage(os.Getenv("BASE_PATH"))
}

func getStorage() (burnafterreading.Storage, error) {
	if os.Getenv("BASE_PATH") != "" {
		return getFileStorage()
	}
	return getS3Storage()
}

func getAuth() burnafterreading.Authorizer {
	return authorizer.BasicHTTPAuthorizer(os.Getenv("USER"), os.Getenv("PASS"))
}

func runServer() error {
	addr := os.Getenv("ADDR")
	log.Printf("Starting HTTP server bound to %q", addr)
	if os.Getenv("USE_SSL") == "" {
		return http.ListenAndServe(addr, nil)
	}
	return http.ListenAndServeTLS(addr, "cert.pem", "cert.key", nil)
}

func main() {
	storageEngine, err := getStorage()
	if err != nil {
		log.Fatalf("error initializing storage: %v", err)
	}
	http.Handle("/", &burnafterreading.Handler{
		Authorizer: getAuth(),
		Storage:    storageEngine,
	})
	log.Fatal(runServer())
}
{'fraction_non_alphanumeric': 0.15991735537190083, 'fraction_numerical': 0.001652892561983471, 'mean_word_length': 5.371052631578947, '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': '7439547', 'n_tokens_mistral': 924, 'n_tokens_neox': 899, 'n_words': 154}