mirror of
https://github.com/Evidlo/remarkable_printer.git
synced 2024-10-19 19:17:37 -04:00
implement writing general content file
This commit is contained in:
parent
d1fe37662a
commit
119b33f538
29
main.go
29
main.go
|
@ -4,22 +4,23 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"flag"
|
||||
"fmt"
|
||||
"io"
|
||||
"net"
|
||||
"os"
|
||||
"os/exec"
|
||||
"bufio"
|
||||
"strings"
|
||||
"io"
|
||||
"flag"
|
||||
"github.com/google/uuid"
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
var (
|
||||
CONN_HOST = "0.0.0.0"
|
||||
CONN_PORT = "9100"
|
||||
LOG_LEVEL = "error"
|
||||
CONN_HOST = "0.0.0.0"
|
||||
CONN_PORT = "9100"
|
||||
LOG_LEVEL = "error"
|
||||
XOCHITL_DIR = "/home/root/.local/share/remarkable/xochitl/"
|
||||
)
|
||||
|
||||
|
@ -37,6 +38,11 @@ const METADATA_TEMPLATE = `{
|
|||
}
|
||||
`
|
||||
|
||||
//const CONTENT_TEMPLATE = `{
|
||||
// "fileType": "pdf"
|
||||
//}
|
||||
//`
|
||||
const CONTENT_TEMPLATE = "{}"
|
||||
|
||||
func main() {
|
||||
|
||||
|
@ -97,7 +103,6 @@ func check(e error) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
// Handles incoming requests.
|
||||
func handleRequest(conn net.Conn) {
|
||||
u, _ := uuid.NewRandom()
|
||||
|
@ -160,5 +165,13 @@ func handleRequest(conn net.Conn) {
|
|||
f.WriteString(fmt.Sprintf(METADATA_TEMPLATE, time.Now().Unix(), title))
|
||||
f.Close()
|
||||
|
||||
// ----- Create .content -----
|
||||
|
||||
cont_path := XOCHITL_DIR + u.String() + ".content"
|
||||
fmt.Println("Saving content file to", cont_path)
|
||||
f, err = os.Create(cont_path)
|
||||
f.WriteString(fmt.Sprintf(CONTENT_TEMPLATE))
|
||||
f.Close()
|
||||
|
||||
conn.Close()
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue