-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
65 lines (57 loc) · 1.24 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package main
import (
"bytes"
"fmt"
"io/ioutil"
"ivai-api/apis"
"ivai-api/models"
"net/http"
"os"
"os/exec"
)
func main() {
// 初始化数据库连接
err := models.InitDB()
if err != nil {
panic(err)
}
// testTransferPNG()
http.ListenAndServe(":8080", apis.Router())
}
// func testTransferPNG() {
// htmlContent := `
// <!DOCTYPE html>
// <html>
// <head>
// <title>My Resume</title>
// </head>
// <body>
// <h1>John Doe</h1>
// <p>Software Developer at Example Corp</p>
// <!-- 更多简历内容 -->
// </body>
// </html>
// `
// tempFile, err := ioutil.TempFile("", "resume-*.html")
// if err != nil {
// fmt.Println("Error creating temp file:", err)
// return
// }
// defer os.Remove(tempFile.Name()) // 确保临时文件被删除
// _, err = tempFile.Write([]byte(htmlContent))
// if err != nil {
// fmt.Println("Error writing to temp file:", err)
// return
// }
// tempFile.Close()
// // 调用wkhtmltoimage
// cmd := exec.Command("wkhtmltoimage", tempFile.Name(), "output.png")
// var out bytes.Buffer
// cmd.Stdout = &out
// err = cmd.Run()
// if err != nil {
// fmt.Println("Error running wkhtmltoimage:", err)
// return
// }
// fmt.Println("Image created successfully.")
// }