Add html output type
This commit is contained in:
parent
424ebb7915
commit
11e59f31b6
|
@ -29,7 +29,7 @@
|
|||
<div class="page-header">
|
||||
<h1>Pantsu Paste</h1>
|
||||
</div>
|
||||
<form action="/save" method="post" class="form-horizontal">
|
||||
<form action="/save/html" method="post" class="form-horizontal">
|
||||
<fieldset>
|
||||
<div class="well">
|
||||
<div class="form-group is-empty">
|
||||
|
@ -451,7 +451,7 @@
|
|||
</form>
|
||||
<div class="well">
|
||||
<code>$ <command> | curl -F 'p=<-' https://p.pantsu.cat/save</code><br/>
|
||||
<code>https://p.pantsu.cat/save/(XML|JSON)</code><br/>
|
||||
<code>https://p.pantsu.cat/save/(XML|JSON|HTML)</code><br/>
|
||||
<code>https://p.pantsu.cat/p/(PASTE)/(lang)</code><br/>
|
||||
<code>https://p.pantsu.cat/del/(PASTE)/(DELKEY)</code<br/>
|
||||
<p>Source: <a href="https://github.com/ewhal/Pastebin">Pastebin</a></p>
|
||||
|
|
12
main.go
12
main.go
|
@ -21,11 +21,6 @@ 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 = "$ <command> | curl -F 'p=<-' " + ADDRESS + "/save" + "\n" + PASTEARGS + URLARGS + DELETE + SOURCE
|
||||
PORT = ":9900"
|
||||
USERNAME = ""
|
||||
PASS = ""
|
||||
|
@ -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, "<p>ID</p><p>"+b.ID+"</p><br/>")
|
||||
io.WriteString(w, "<p>hash</p><p>"+b.HASH+"</p><br/>")
|
||||
io.WriteString(w, "<p>URL</p><a href='"+b.URL+"'>"+b.URL+"</a><br/>")
|
||||
io.WriteString(w, "<p>hash</p><p>"+b.SIZE+"</p><br/>")
|
||||
io.WriteString(w, "<a href='"+b.URL+"/p/"+b.DELKEY+"'>"+b.DELKEY+"</a>")
|
||||
|
||||
default:
|
||||
io.WriteString(w, b.URL+"\n")
|
||||
|
|
Loading…
Reference in New Issue