<commit_before>// httpserver.go
package main

import (
	"encoding/json"
	"flag"
	"log"
	"net/http"
	"net/http/httputil"
	"net/url"
	"os"
	"strconv"
	"strings"
)

type Redirection struct {
	Path string
	URL  string
}

type Router struct {
	Host         string
	Port         int
	Redirections []Redirection
}

const DefaultPort = 8888
const DefaultHost = "0.0.0.0"

var logFlag = flag.String("log", "", "Define log file")
var routerFilePath = flag.String("router", "router.json", "Define router file")
var sslKeyFile = flag.String("sslKey", "", "Path to key file")
var sslCertFile = flag.String("sslCert", "", "Path to certificate file")

var logger *log.Logger

func Log(handler http.Handler) http.Handler {
	return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		logger.Printf("%s %s %s", r.RemoteAddr, r.Method, r.URL)
		if origin := r.Header.Get("Origin"); origin != "" {
			w.Header().Set("Access-Control-Allow-Origin", origin)
		}
		//		w.Header().Set("Access-Control-Allow-Origin", "3ds.com")
		w.Header().Set("Access-Control-Allow-Methods", "POST, GET, OPTIONS, PUT, DELETE")
		w.Header().Set("Access-Control-Allow-Headers", "Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, Origin, Accept, Format, NoDefault, x-requested-method, x-requested-with, x-request")
		w.Header().Set("Access-Control-Allow-Credentials", "true")
		handler.ServeHTTP(w, r)
	})
}

func main() {
	flag.Parse()
	if *logFlag == "" {
		// use default logger
		logger = log.New(os.Stderr, "", log.LstdFlags)
		log.Println("Log to stderr")
	} else {
		logFile, err := os.Create(*logFlag)
		if err != nil {
			log.Println(err)
			return
		}
		defer logFile.Close()
		log.Printf("Log to %s", *logFlag)
		logger = log.New(logFile, "", log.LstdFlags)
	}
	var router Router<commit_msg>print host<commit_after>// httpserver.go
package main

import (
	"encoding/json"
	"flag"
	"log"
	"net/http"
	"net/http/httputil"
	"net/url"
	"os"
	"strconv"
	"strings"
)

type Redirection struct {
	Path string
	URL  string
}

type Router struct {
	Host         string
	Port         int
	Redirections []Redirection
}

const DefaultPort = 8888
const DefaultHost = "0.0.0.0"

var logFlag = flag.String("log", "", "Define log file")
var routerFilePath = flag.String("router", "router.json", "Define router file")
var sslKeyFile = flag.String("sslKey", "", "Path to key file")
var sslCertFile = flag.String("sslCert", "", "Path to certificate file")

var logger *log.Logger

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

func main() {
	flag.Parse()
	if *logFlag == "" {
		// use default logger
		logger = log.New(os.Stderr, "", log.LstdFlags)
		log.Println("Log to stderr")
	} else {
		logFile, err := os.Create(*logFlag)
		if err != nil {
			log.Println(err)
			return
		}
		defer logFile.Close()
		log.Printf("Log to %s", *logFlag)
		logger = log.New(logFile, "", log.LstdFlags)
	}
	var router Router
{'fraction_non_alphanumeric': 0.16535690897184022, 'fraction_numerical': 0.005566470203012442, 'mean_word_length': 3.880191693290735, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '1227190', 'n_tokens_mistral': 1162, 'n_tokens_neox': 1115, 'n_words': 265}