fix: fix permission error
This commit is contained in:
parent
c9c7834291
commit
4c1ad32681
1
.gitignore
vendored
1
.gitignore
vendored
@ -25,4 +25,5 @@ _testmain.go
|
|||||||
*.prof
|
*.prof
|
||||||
|
|
||||||
/vendor
|
/vendor
|
||||||
|
debug
|
||||||
#main
|
#main
|
||||||
|
@ -3,11 +3,7 @@ LABEL maintainer="MiaoWoo<admin@yumc.pw>"
|
|||||||
|
|
||||||
ENV LANG en_US.UTF-8
|
ENV LANG en_US.UTF-8
|
||||||
|
|
||||||
RUN yum install -y fontconfig git nano
|
RUN yum install -y fontconfig
|
||||||
RUN git clone https://github.com/powerline/fonts.git --depth=1 && \
|
|
||||||
cd fonts && \
|
|
||||||
./install.sh && \
|
|
||||||
fc-cache
|
|
||||||
|
|
||||||
WORKDIR /root
|
WORKDIR /root
|
||||||
|
|
||||||
|
11
main.go
11
main.go
@ -18,11 +18,20 @@ func main() {
|
|||||||
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
||||||
uid, _ := uuid.NewV4()
|
uid, _ := uuid.NewV4()
|
||||||
uuid := "html2pic-" + uid.String()
|
uuid := "html2pic-" + uid.String()
|
||||||
url, html := r.PostFormValue("url"), r.PostFormValue("html")
|
var (
|
||||||
|
url string
|
||||||
|
html string
|
||||||
|
)
|
||||||
|
if r.Method == "GET" {
|
||||||
|
url, html = r.FormValue("url"), r.FormValue("html")
|
||||||
|
} else {
|
||||||
|
url, html = r.PostFormValue("url"), r.PostFormValue("html")
|
||||||
|
}
|
||||||
tempFile := *tempDir + "/" + uuid + ".html"
|
tempFile := *tempDir + "/" + uuid + ".html"
|
||||||
if html != "" {
|
if html != "" {
|
||||||
ioutil.WriteFile(tempFile, []byte("<!DOCTYPE html><html lang=\"zh\"><head><meta charset=\"UTF-8\"></head><body style=\"margin: 0;padding: 0;\">"+html+"</body></html>"), os.ModeAppend)
|
ioutil.WriteFile(tempFile, []byte("<!DOCTYPE html><html lang=\"zh\"><head><meta charset=\"UTF-8\"></head><body style=\"margin: 0;padding: 0;\">"+html+"</body></html>"), os.ModeAppend)
|
||||||
url = "file://" + tempFile
|
url = "file://" + tempFile
|
||||||
|
os.Chmod(tempFile, 0755)
|
||||||
defer os.Remove(tempFile)
|
defer os.Remove(tempFile)
|
||||||
}
|
}
|
||||||
if url == "" {
|
if url == "" {
|
||||||
|
Loading…
Reference in New Issue
Block a user