-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 7deddca
Showing
9 changed files
with
137 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
upload.py | ||
upload.sh |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
test2 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
test1 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"schema" : { | ||
"messages" : { | ||
"message" : "text" | ||
} | ||
}, | ||
"indexes" : [ | ||
["messages", "timestamp"] | ||
] | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Example App</title> | ||
<script type="text/javascript" src="jquery-2.1.3.min.js"></script> | ||
</head> | ||
<body> | ||
<script type="text/javascript"> | ||
$(document).ready(function(){ | ||
setTimeout(updateLog, 1000); | ||
$("#send_mesg").click(function(){ | ||
$.ajax({ | ||
type: "POST", | ||
url: "add_record", | ||
data: JSON.stringify({ | ||
_table: "messages", | ||
message: $("#to_send").val() | ||
}), | ||
contentType: "application/json", | ||
success: function(resp) {}, | ||
error: function(resp) {} | ||
}); | ||
}); | ||
}); | ||
function updateLog() { | ||
$.ajax({ | ||
type: "POST", | ||
url: "query", | ||
data: JSON.stringify({ | ||
query: "SELECT message FROM messages ORDER BY timestamp DESC LIMIT 20" | ||
}), | ||
contentType: "application/json", | ||
success: function(resp) { | ||
$("#msgid").html(JSON.stringify(resp.results)); | ||
setTimeout(updateLog, 1000); | ||
}, | ||
error: function(resp) { | ||
$("#msgid").html("Whoops, can't get messages") | ||
setTimeout(updateLog, 1000); | ||
} | ||
}); | ||
} | ||
</script> | ||
|
||
<p> | ||
This is a test app. All it does is display the top 20 messages sent by anyone recently, with | ||
the ability to add your own message to the bottom. | ||
In that regard, you might think of it as a primitive chat room. The html is really the worst, | ||
since I'm a terrible web dev, but hey, it's simple. | ||
</p> | ||
|
||
<p>Put message to send here: </p> | ||
<input type="text" id="to_send", name="message" required="required" /> | ||
<input type="button" id="send_mesg" value="Go" /> | ||
|
||
<div id="msgid"> | ||
</div> | ||
|
||
<p>My first paragraph.</p> | ||
|
||
</body> | ||
</html> | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
5a6961ca9a2d774b2a53e7f4b93d285cba586ac3 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#7751e2923d2fb1c807881f0421b07df6cf93a4d8 | ||
import urllib, mimetypes, pycurl | ||
import sys | ||
import os | ||
|
||
# Read .flockignore | ||
# Read supplied Directory & subdirectories | ||
# ignore all files listed in .flockignore | ||
# find MIME | ||
# Upload | ||
|
||
# Usage: upload.py appId directory | ||
print sys.argv | ||
|
||
appId = sys.argv[1] | ||
directory = sys.argv[2] | ||
|
||
IGNORE_FILE = ".flockignore" | ||
ignore_filepath = "%s/%s" % (directory, ".flockignore") | ||
|
||
print "isfile? : " + str(os.path.isfile(ignore_filepath)) | ||
|
||
ignore_content = {} | ||
if os.path.isfile(ignore_filepath): | ||
with open(ignore_filepath) as f: | ||
for line in f: | ||
l = line.rstrip('\n') | ||
if len(l) > 0: | ||
ignore_content[l] = True | ||
|
||
print ignore_content | ||
|
||
# traverse root directory, and list directories as dirs and files as files | ||
for root, dirs, files in os.walk("."): | ||
path = root.split('/') | ||
print (len(path) - 1) *'---' , os.path.basename(root) | ||
for file in files: | ||
print len(path)*'---', file, ' ', dirs, ' ', root | ||
|
||
""" | ||
mime = MimeTypes() | ||
url = urllib.pathname2url('Upload.xml') | ||
mime_type = mime.guess_type(url) | ||
c = pycurl.Curl() | ||
c.setopt(c.PUT, 1) | ||
c.setopt(c.URL, "http://127.0.0.1:8000/%s/%s") | ||
c.setopt(c.HTTPPOST, [("file1", (c.FORM_FILE, "c:\\tmp\\download\\test.jpg"))]) | ||
c.setopt(c.HTTPHEADER, ["Content-Type: %s" % (mime_type)]) | ||
#c.setopt(c.VERBOSE, 1) | ||
c.perform() | ||
c.close() | ||
""" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#!/bin/bash | ||
curl -v -X PUT --header "Content-Type: $1" localhost:8000/`cat tid`/$2 --data-binary @$2 |