2023-01-24 15:50:38 +01:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2023-01-27 16:23:22 +01:00
|
|
|
"errors"
|
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
|
2023-01-29 19:24:15 +01:00
|
|
|
"github.com/otiai10/copy"
|
2023-01-25 22:14:27 +01:00
|
|
|
"nikurasu.gay/static-hoster/envloader"
|
2023-01-24 15:50:38 +01:00
|
|
|
"nikurasu.gay/static-hoster/router"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2023-01-26 18:52:03 +01:00
|
|
|
var env = envloader.Load()
|
2023-01-27 16:23:22 +01:00
|
|
|
if _, err := os.Stat(fmt.Sprintf("%s404.html", env.StaticDir)); errors.Is(err, os.ErrNotExist) {
|
2023-01-29 19:24:15 +01:00
|
|
|
if _, err := os.Stat("/usr/share/static-hoster/html"); errors.Is(err, os.ErrNotExist) {
|
|
|
|
os.Create(fmt.Sprintf("%s404.html", env.StaticDir))
|
|
|
|
} else {
|
|
|
|
copy.Copy("/usr/share/static-hoster/html", env.StaticDir)
|
|
|
|
}
|
2023-01-27 16:23:22 +01:00
|
|
|
}
|
2023-01-25 22:14:27 +01:00
|
|
|
r := router.Create(env)
|
2023-01-26 18:52:03 +01:00
|
|
|
r.Run(env.Port)
|
2023-01-24 15:50:38 +01:00
|
|
|
}
|