started go module
This commit is contained in:
parent
f03a8307a4
commit
2d66daa1da
|
@ -0,0 +1,5 @@
|
|||
module tildegit.com/drevil/comics
|
||||
|
||||
go 1.19
|
||||
|
||||
require github.com/akamensky/argparse v1.4.0
|
|
@ -0,0 +1,2 @@
|
|||
github.com/akamensky/argparse v1.4.0 h1:YGzvsTqCvbEZhL8zZu2AiA5nq805NZh75JNj4ajn1xc=
|
||||
github.com/akamensky/argparse v1.4.0/go.mod h1:S5kwC7IuDcEr5VeXtGPRVZ5o/FdhcMlQz4IZQuw64xA=
|
|
@ -1,14 +1,17 @@
|
|||
package comics
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"net/http"
|
||||
"database/sql"
|
||||
_ "github.com/mattn/go-sqlite3"
|
||||
|
||||
"github.com/akamensky/argparse"
|
||||
)
|
||||
|
||||
db *sql.DB = nil
|
||||
dbPath string = "./db.sqlite"
|
||||
|
||||
type Comic {
|
||||
ID string
|
||||
|
@ -85,3 +88,25 @@ func renderTemplate(w http.ResponseWriter, t string, p *Page) {
|
|||
func comicView(w http.ResponseWriter, r * http.Request, n string) {
|
||||
|
||||
}
|
||||
|
||||
func main() {
|
||||
parser := argparse.NewParser("comics", "Webserver for comics distribution websites")
|
||||
|
||||
dbPath = parser.Flag("d", "db-path", &argparse.Options{
|
||||
Required: false, Help: "Sets path to database file", Default: dbPath
|
||||
})
|
||||
mediaPath = parser.Flag("m", "media-path", &argparser.Options{
|
||||
Required: false, Help: "Sets path to media directory", Default: mediaPath
|
||||
})
|
||||
|
||||
db, err := sql.Open("sqlite3", dbPath)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer db.Close()
|
||||
|
||||
_, err := db.Exec(dbSquema)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue