Esempio n. 1
0
File: main.go Progetto: diptanu/seli
func stats_handler(res http.ResponseWriter, req *http.Request) {
	res.Header().Set("Content-Type", "application/json")
	b, err := stats.SeliStats().Resource()
	if err != nil {
		log.Fatal(err)
	}
	res.Write(b)

}
Esempio n. 2
0
File: main.go Progetto: diptanu/seli
func upload_handler(res http.ResponseWriter, req *http.Request) {
	file, handler, err := req.FormFile("filedata")
	if err != nil {
		log.Printf("%s", err)
	}
	data, err := ioutil.ReadAll(file)
	if err != nil {
		log.Printf("%s", err)
	}
	file_name := path.Join(repo_path, handler.Filename)
	err = ioutil.WriteFile(file_name, data, 0777)
	if err != nil {
		log.Printf("%s", err)
	}
	log.Println("Written a new file :" + file_name)
	stats.SeliStats().Update()
	res.Header().Set("Content-Type", "text/plain")
	res.Write([]byte(req.Method))
}