<commit_before>package ipjogli

import (
	"fmt"
	"net"
	"net/http"
)

func init() {
	http.HandleFunc("/", handler)
}

func handler(w http.ResponseWriter, r *http.Request) {
	addr, _, err := net.SplitHostPort(r.RemoteAddr)
	if err != nil {
		w.WriteHeader(http.StatusInternalServerError)
		return
	}
	fmt.Fprintf(w, addr+"\n")
}<commit_msg>Correctly handle IP on GAE vs. standalone<commit_after>package ipjogli

import (
	"fmt"
	"net"
	"net/http"
)

func init() {
	http.HandleFunc("/", handler)
}

func handler(w http.ResponseWriter, r *http.Request) {
	var addr string
	if _, ok := r.Header["X-Appengine-Remote-Addr"]; ok {
		addr = r.RemoteAddr
	} else {
		var err error
		addr, _, err = net.SplitHostPort(r.RemoteAddr)
		if err != nil {
			w.WriteHeader(http.StatusInternalServerError)
			return
		}
	}
	fmt.Fprintf(w, addr+"\n")
}
{'fraction_non_alphanumeric': 0.15366146458583432, 'fraction_numerical': 0.0, 'mean_word_length': 3.9642857142857144, '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': '6554846', 'n_tokens_mistral': 336, 'n_tokens_neox': 321, 'n_words': 69}