Created
September 5, 2014 16:05
-
-
Save JeffSpies/0e7e2fe532d325dd8ced to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"log" | |
"net/http" | |
) | |
func UploadHandler(w http.ResponseWriter, req *http.Request) { | |
switch req.Method { | |
case "POST": | |
err2 := req.ParseMultipartForm(10000000) | |
if err2 != nil { | |
return | |
} | |
m := req.MultipartForm | |
files := m.File["data"] | |
log.Print(files[0].Filename) | |
default: | |
log.Print("Nope") | |
} | |
} | |
func main() { | |
http.HandleFunc("/", UploadHandler) | |
err := http.ListenAndServe(":5001", nil) | |
if err != nil { | |
log.Fatal("Error: ", err) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tornado.ioloop | |
import tornado.web | |
class UploadFile(tornado.web.RequestHandler): | |
def post(self): | |
print self.request.files['data'][0]['filename'] | |
application = tornado.web.Application([ | |
(r"/", UploadFile) | |
]) | |
if __name__ == "__main__": | |
application.listen(5000) | |
tornado.ioloop.IOLoop.instance().start() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment