Face identification and recognition scalable server with multiple face directories.
https://github.com/ehp/faceserver
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
1.4 KiB
39 lines
1.4 KiB
package main |
|
|
|
import ( |
|
"fmt" |
|
"log" |
|
"net/http" |
|
"strconv" |
|
|
|
"gitea.ehp.cz/Aprar/faceserver/apiserver" |
|
"github.com/spf13/viper" |
|
) |
|
|
|
func main() { |
|
viper.SetConfigName("apiserver") // name of config file (without extension) |
|
viper.AddConfigPath("/etc/faceserver/") // path to look for the config file in |
|
viper.AddConfigPath("$HOME/.faceserver") // call multiple times to add many search paths |
|
viper.AddConfigPath(".") // optionally look for config in the working directory |
|
viper.SetEnvPrefix("AS_") |
|
viper.AutomaticEnv() |
|
err := viper.ReadInConfig() // Find and read the config file |
|
if err != nil { // Handle errors reading the config file |
|
panic(fmt.Errorf("Fatal error config file: %s \n", err)) |
|
} |
|
|
|
apiserver.Dbo, err = apiserver.NewStorage(viper.GetString("db.user"), viper.GetString("db.password"), viper.GetString("db.name"), viper.GetString("db.host")) |
|
if err != nil { |
|
panic(fmt.Errorf("Fatal error database connection: %s \n", err)) |
|
} |
|
|
|
http.Handle("/", http.FileServer(http.Dir("./public"))) |
|
|
|
fs := http.FileServer(http.Dir("./files")) |
|
http.Handle("/files/", http.StripPrefix("/files", fs)) |
|
|
|
http.HandleFunc("/learn", apiserver.Learn) |
|
http.HandleFunc("/recognize", apiserver.Recognize) |
|
log.Println("Running") |
|
log.Fatal(http.ListenAndServe(":" + strconv.Itoa(viper.GetInt("port")), nil)) |
|
}
|
|
|