<commit_before>package main

import (
	"database/sql"
	"encoding/json"
	"fmt"
	"html/template"
	"log"
	"net/http"
	"strconv"
	"strings"

	"github.com/gorilla/mux"
	_ "github.com/lib/pq" // _ means to import only for its side-effects (initialization)
)

// App : struct to expose references to the router and database
type App struct {
	Router *mux.Router
	DB     *sql.DB
}

// Initialize : func to initialize database with connection info, add routes
func (app *App) Initialize(user, password, dbname string) {
	connectionString := fmt.Sprintf("user=%s password=%s dbname=%s sslmode=disable", user, password, dbname)

	var err error
	app.DB, err = sql.Open("postgres", connectionString)
	if err != nil {
		log.Fatal(err)
	}

	app.Router = mux.NewRouter()
	app.initializeRoutes()
}

// Run : func to start the main application
func (app *App) Run(addr string) {
	log.Fatal(http.ListenAndServe(":8080", app.Router))
}

// initializeRoutes : func to initialize routes
func (app *App) initializeRoutes() {
	app.Router.HandleFunc("/", indexHandler).Methods("GET")
	app.Router.HandleFunc("/hello", helloHandler).Methods("GET")<commit_msg>App Run func uses addr given<commit_after>package main

import (
	"database/sql"
	"encoding/json"
	"fmt"
	"html/template"
	"log"
	"net/http"
	"strconv"
	"strings"

	"github.com/gorilla/mux"
	_ "github.com/lib/pq" // _ means to import only for its side-effects (initialization)
)

// App : struct to expose references to the router and database
type App struct {
	Router *mux.Router
	DB     *sql.DB
}

// Initialize : func to initialize database with connection info, add routes
func (app *App) Initialize(user, password, dbname string) {
	connectionString := fmt.Sprintf("user=%s password=%s dbname=%s sslmode=disable", user, password, dbname)

	var err error
	app.DB, err = sql.Open("postgres", connectionString)
	if err != nil {
		log.Fatal(err)
	}

	app.Router = mux.NewRouter()
	app.initializeRoutes()
}

// Run : func to start the main application at specifc port
func (app *App) Run(addr string) {
	log.Fatal(http.ListenAndServe(addr, app.Router))
}

// initializeRoutes : func to initialize routes
func (app *App) initializeRoutes() {
	app.Router.HandleFunc("/", indexHandler).Methods("GET")
	app.Router.HandleFunc("/hello", helloHandler).Methods("GET")
{'fraction_non_alphanumeric': 0.13743455497382198, 'fraction_numerical': 0.0017452006980802793, 'mean_word_length': 4.446555819477434, 'pattern_counts': {'":': 1, '<': 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': '4756237', 'n_tokens_mistral': 775, 'n_tokens_neox': 753, 'n_words': 215}