Commit of all existing code.

This commit is contained in:
2024-12-06 11:55:31 -07:00
commit 1f7234997b
17 changed files with 498 additions and 0 deletions
+38
View File
@@ -0,0 +1,38 @@
package cmd
import (
"frostfire.io/dir2opdspse/app/routes"
"github.com/gorilla/mux"
"github.com/urfave/cli/v2"
"net/http"
"strconv"
"time"
)
var Serve = cli.Command{
Name: "serve",
Usage: "Starts the webserver",
Description: "Start the Flux webserver. That's all you need to run.",
Action: runServe,
Flags: []cli.Flag{
intFlag("port, p", 3000, "Web server port"),
},
}
func runServe(c *cli.Context) error {
r := mux.NewRouter()
fs := http.FileServer(http.Dir("books/"))
r.PathPrefix("/manga/").Handler(http.StripPrefix("/manga", fs))
routes.Init(c, r)
srv := &http.Server{
Handler: r,
Addr: ":" + strconv.Itoa(c.Int("port")),
WriteTimeout: 15 * time.Second,
ReadTimeout: 15 * time.Second,
}
return srv.ListenAndServe()
}