Skip to content

Commit

Permalink
up
Browse files Browse the repository at this point in the history
  • Loading branch information
geraldb committed Apr 3, 2023
1 parent 0da610d commit 1813f65
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 52 deletions.
2 changes: 1 addition & 1 deletion .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ builds:
# Binary name.
# Can be a path (e.g. `bin/app`) to wrap the binary in a directory.
# Default is the name of the project directory.
binary: artbase
binary: artbased


# GOOS list to build for.
Expand Down
14 changes: 11 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Find the archives to download - about 3 Megabytes (MB) - for Windows, Linux and
Unpack the archive (e.g. `artbase-*.tar.gz` or `artbase-*.zip`) and than start / run the binary:

```
$ artbase
$ artbased
```

This will start-up a (web) server (listening on port 8080). To test open up `http://localhost:8080` in your browser (to get the index web page listing all collections).
Expand All @@ -22,14 +22,14 @@ This will start-up a (web) server (listening on port 8080). To test open up `htt
Use / issue / type (in the `/artbase.server` directory):

```
$ go build artbase.go
$ go build artbased.go
```

to get a zero-config x-copy binary for your operation system / architecture.
To run use:

```
$ artbase
$ artbased
```

This will start-up a (web) server (listening on port 8080). To test open up `http://localhost:8080` in your browser (to get the index web page listing all collections).
Expand Down Expand Up @@ -59,6 +59,14 @@ The pixel art collections pre-configured¹ include:



Note: You can use your own collections - use the `-c/--config` flag
and pass along a file path or a web url to the collection dataset in
the comma-separated values (.csv) format e.g. `$ artbased --config ./collections.csv`.





### (Web) Services


Expand Down
48 changes: 0 additions & 48 deletions artbase.go

This file was deleted.

75 changes: 75 additions & 0 deletions artbased.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
package main

import (
"fmt"
// "log"
"os"
"net/http"
"strings"
"strconv"
"flag"


"github.com/pixelartexchange/artbase.server/artbase"
"github.com/pixelartexchange/artbase.server/serve"
)



func main() {

//// note:
// download "standard" collections for now,
// yes, you can - use / set-up your own collections

var configValue string
configDef := "https://github.com/pixelartexchange/artbase.server/raw/master/collections.csv"
// configDef := "https://github.com/pixelartexchange/ordbase.server/raw/master/collections.csv"
configUsage := "path or url to collections dataset"

flag.StringVar(&configValue, "config", configDef, configUsage)
flag.StringVar(&configValue, "c", configDef, configUsage+" (shorthand)")


var portValue int
portDef := 8080
portUsage := "port"

// check for port in env settings - required by heroku et al
portEnv := os.Getenv( "PORT" )
if portEnv != "" {
if i, err := strconv.Atoi( portEnv ); err == nil {
portDef = i // change default to env variable; if error ignore for now
}
}

flag.IntVar(&portValue, "port", portDef, portUsage )
flag.IntVar(&portValue, "p", portDef, portUsage+" (shorthand)")


flag.Parse()

var collections []*artbase.Collection

if strings.HasPrefix( configValue, "http://" ) ||
strings.HasPrefix( configValue, "https://" ) {
collections = artbase.DownloadCollections( configValue )
} else {
collections = artbase.ReadCollections( configValue )
}


serve := serve.NewRouter( collections )


// default addr to localhost:8080 for now
// for windows include localhost to avoid firewall warning/popup
// if binding to :8080 only - why? why not?

addr := "localhost:" + strconv.Itoa( portValue )

http.ListenAndServe( addr, serve )

fmt.Println( "Bye!" )
}

0 comments on commit 1813f65

Please sign in to comment.