From cdf50c04e78305c20f9faf08f9ca04ff296e6002 Mon Sep 17 00:00:00 2001 From: Eliot Whalan Date: Thu, 23 Jun 2016 13:45:00 +1000 Subject: [PATCH] Add html output type --- assets/index.html | 4 ++-- main.go | 26 ++++++++++++++------------ 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/assets/index.html b/assets/index.html index b13ffb6..3472821 100644 --- a/assets/index.html +++ b/assets/index.html @@ -29,7 +29,7 @@ -
+
@@ -451,7 +451,7 @@
$ <command> | curl -F 'p=<-' https://p.pantsu.cat/save
- https://p.pantsu.cat/save/(XML|JSON)
+ https://p.pantsu.cat/save/(XML|JSON|HTML)
https://p.pantsu.cat/p/(PASTE)/(lang)
https://p.pantsu.cat/del/(PASTE)/(DELKEY)

Source: Pastebin

diff --git a/main.go b/main.go index 0c4d9d8..a203f7c 100644 --- a/main.go +++ b/main.go @@ -19,18 +19,13 @@ import ( ) const ( - ADDRESS = "http://localhost:9900" - LENGTH = 6 - DELETE = ADDRESS + "/del/{PASTE}/{DELKEY}\n" - PASTEARGS = ADDRESS + "/p/{PASTE}/(python|language)\n" - URLARGS = ADDRESS + "/save/XML|JSON\n" - SOURCE = "Source: https://github.com/ewhal/Pastebin\n" - TEXT = "$ | curl -F 'p=<-' " + ADDRESS + "/save" + "\n" + PASTEARGS + URLARGS + DELETE + SOURCE - PORT = ":9900" - USERNAME = "" - PASS = "" - NAME = "" - DATABASE = USERNAME + ":" + PASS + "@/" + NAME + "?charset=utf8" + ADDRESS = "http://localhost:9900" + LENGTH = 6 + PORT = ":9900" + USERNAME = "" + PASS = "" + NAME = "" + DATABASE = USERNAME + ":" + PASS + "@/" + NAME + "?charset=utf8" ) type Response struct { @@ -169,6 +164,13 @@ func saveHandler(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/xml") w.Write(x) + case "html": + w.Header().Set("Content-Type", "text/html") + io.WriteString(w, "

ID

"+b.ID+"


") + io.WriteString(w, "

hash

"+b.HASH+"


") + io.WriteString(w, "

URL

"+b.URL+"
") + io.WriteString(w, "

hash

"+b.SIZE+"


") + io.WriteString(w, ""+b.DELKEY+"") default: io.WriteString(w, b.URL+"\n")