<commit_before>package main

import (
	"fmt"
	//"io"
	//"io/ioutil"
	"log"
	"net/http"
	"os"
	//"strings"
)

func receive(w http.ResponseWriter, r *http.Request) {

	wholeurl := r.URL.String()
	body := r.URL.Query()["Body"]
	phone := r.URL.Query()["From"]

	fmt.Printf("wholeurl:\n%s\n\nPhone: %s\nBody: %s,\n\n", wholeurl, phone, body)
}

func main() {
	// Read the port from the file.
	//fileContents, err := ioutil.ReadFile("port.txt")
	//if err != nil {
	//	log.Fatal(err)
	//}
	//port := strings.TrimSpace(string(fileContents))

	if len(os.Args) != 2 {
		log.Fatal("usage: server.go port")
	}

	port := ":" + os.Args[1]

	// Start the server.
	fmt.Printf("Starting TxtRoulette server on port %s...\n", port)
	http.HandleFunc("/receive/", receive)
	log.Fatal(http.ListenAndServe(port, nil))
}
<commit_msg>added sendSMS to send a text message to a phone number<commit_after>package main

import (
	"fmt"
	//"io"
	"io/ioutil"
	"log"
	"net/http"
	"os"
	"net/url"
	"strings"
)

func receive(w http.ResponseWriter, r *http.Request) {

	wholeurl := r.URL.String()
	body := r.URL.Query()["Body"]
	phone := r.URL.Query()["From"]

	fmt.Printf("wholeurl:\n%s\n\nPhone: %s\nBody: %s,\n\n", wholeurl, phone, body)
}

func sendSMS(phonenumber , message string) {
	
	apiusr := os.Getenv("TWILIO_APIUSR")
	apikey := os.Getenv("TWILIO_APIKEY")
	
	u := "https://api.twilio.com/2010-04-01/Accounts/<KEY>/Messages.json"
	
	hc := http.Client{}
	form := url.Values{}
	form.Add("To", phonenumber)
	form.Add("From", "+13208398785")
	form.Add("Body", message)

	req, err := http.NewRequest("POST", u, strings.NewReader(form.Encode()))
        
	if err != nil {
		log.Fatal(err)
	}

	req.SetBasicAuth(apiusr, apikey)
	req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
	//fmt.Printf("the request was: \n%v\n\n",req)

	resp, err := hc.Do(req)
        if err != nil {
		log.Fatal(err)
	}
	if resp.StatusCode != 201 {
		defer resp.Body.Close()
		body, err :=ioutil.ReadAll(resp.Body)
		if err != nil {
			log.Fatal(err)
		}
		log.Print(body)
	}
}

func main() {
	// Read the port from the file.
	//fileContents, err := ioutil.ReadFile("port.txt")
	//if err != nil {
	//	log.Fatal(err)
	//}
	//port := strings.TrimSpace(string(fileContents))

	if len(os.Args) != 2 {
		log.Fatal("usage: server.go port")
	}

	port := ":" + os.Args[1]

	//fmt.Printf("sending text message\n")
	//sendSMS("+17744024454", "Test message from Twilio")

	// Start the server.
	fmt.Printf("Starting TxtRoulette server on port %s...\n", port)
	http.HandleFunc("/receive/", receive)
	log.Fatal(http.ListenAndServe(port, nil))
}

{'fraction_non_alphanumeric': 0.2027756360832691, 'fraction_numerical': 0.014263685427910563, 'mean_word_length': 3.5287958115183247, 'pattern_counts': {'":': 2, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 1, 'lorem ipsum': 0, 'www.': 1, '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': '1134152', 'n_tokens_mistral': 1121, 'n_tokens_neox': 1053, 'n_words': 208}