mirror of
https://github.com/writeas/nerds
synced 2018-07-20 12:35:21 +00:00
Add write.as command line / curl tool
This commit is contained in:
parent
6c193334e7
commit
83bde1364b
24
static/cmd.txt
Normal file
24
static/cmd.txt
Normal file
@ -0,0 +1,24 @@
|
||||
Welcome to cmd.write.as!
|
||||
|
||||
████████████████████████████████████████████████████
|
||||
█ █
|
||||
█ <command> | curl -F 'w=<-' http://cmd.write.as █
|
||||
█ █
|
||||
████████████████████████████████████████████████████
|
||||
|
||||
Simple text pasting / publishing. Run then share the link you get.
|
||||
|
||||
No funny stuff — all posts show up on write.as once the command finishes. No
|
||||
sign up, no publicized URLs, no analytics. Publish what you like.
|
||||
|
||||
This is the pre-pre-alpha of write.as, showcasing some of what you'll see later.
|
||||
We have many plans, all based in text/plain. Keep up to date with us @writeas__
|
||||
on Twitter or get notified when we launch at https://write.as.
|
||||
|
||||
|
||||
You can also use telnet: nerds.write.as
|
||||
|
||||
|
||||
BUGS/ISSUES/YOU HACKED THE GIBSON
|
||||
—————————————————————————————————
|
||||
Report bugs and flaws to hello@write.as.
|
54
write-curl.go
Normal file
54
write-curl.go
Normal file
@ -0,0 +1,54 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"flag"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
|
||||
"github.com/writeas/writeas-telnet/store"
|
||||
)
|
||||
|
||||
var (
|
||||
outDir string
|
||||
indexPage []byte
|
||||
)
|
||||
|
||||
func poster(w http.ResponseWriter, r *http.Request) {
|
||||
post := r.FormValue("w")
|
||||
|
||||
if post == "" {
|
||||
fmt.Fprintf(w, "%s", indexPage)
|
||||
return
|
||||
}
|
||||
|
||||
filename, err := store.SavePost(outDir, []byte(post))
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
fmt.Fprint(w, "Couldn't save :(\n")
|
||||
return
|
||||
}
|
||||
fmt.Fprintf(w, "https://write.as/%s\n", filename)
|
||||
}
|
||||
|
||||
func main() {
|
||||
outDirPtr := flag.String("o", "/home/matt", "Directory where text files will be stored.")
|
||||
staticDirPtr := flag.String("s", "./static", "Directory where required static files exist.")
|
||||
portPtr := flag.Int("p", 8080, "Port to listen on.")
|
||||
flag.Parse()
|
||||
|
||||
outDir = *outDirPtr
|
||||
|
||||
fmt.Print("Initializing...")
|
||||
var err error
|
||||
indexPage, err = ioutil.ReadFile(*staticDirPtr + "/cmd.txt")
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
fmt.Println("DONE")
|
||||
|
||||
fmt.Printf("Serving on http://localhost:%d\n", *portPtr)
|
||||
|
||||
http.HandleFunc("/", poster)
|
||||
http.ListenAndServe(fmt.Sprintf(":%d", *portPtr), nil)
|
||||
}
|
Loading…
Reference in New Issue
Block a user