A web server for quba.fr that resizes images.
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.
 
 

59 lines
1.0 KiB

  1. package main
  2. import (
  3. "log"
  4. "os"
  5. "github.com/urfave/cli"
  6. "git.quba.fr/qbarrand/quba.fr-server/pkg"
  7. )
  8. func main() {
  9. var (
  10. addr string
  11. dir string
  12. quality uint
  13. )
  14. app := cli.NewApp()
  15. app.Name = "server"
  16. app.Flags = []cli.Flag{
  17. cli.StringFlag{
  18. Name: "addr",
  19. Usage: "the address and port on which this server should listen",
  20. EnvVar: "ADDR",
  21. Value: ":8080",
  22. Destination: &addr,
  23. },
  24. cli.StringFlag{
  25. Name: "dir",
  26. Usage: "path to the served directory",
  27. EnvVar: "DIR",
  28. Value: ".",
  29. Destination: &dir,
  30. },
  31. cli.UintFlag{
  32. Name: "quality",
  33. Usage: "quality of the output JPG file",
  34. EnvVar: "QUALITY",
  35. FilePath: "",
  36. Value: 80,
  37. Destination: &quality,
  38. },
  39. }
  40. app.Action = func(_ *cli.Context) error {
  41. log.Print("Serving contents from " + dir)
  42. log.Print("Starting the server on " + addr)
  43. return pkg.StartServer(addr, dir, quality)
  44. }
  45. if err := app.Run(os.Args); err != nil {
  46. log.Fatal(err)
  47. }
  48. }