Skip to content

Commit

Permalink
First commit
Browse files Browse the repository at this point in the history
  • Loading branch information
mhoak committed Jan 19, 2015
0 parents commit 7deddca
Show file tree
Hide file tree
Showing 9 changed files with 137 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .flockignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
upload.py
upload.sh
1 change: 1 addition & 0 deletions Sub/sub2/test2
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test2
1 change: 1 addition & 0 deletions Sub/test1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test1
10 changes: 10 additions & 0 deletions _schema
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"schema" : {
"messages" : {
"message" : "text"
}
},
"indexes" : [
["messages", "timestamp"]
]
}
63 changes: 63 additions & 0 deletions index.html
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>

4 changes: 4 additions & 0 deletions jquery-2.1.3.min.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions tid
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
5a6961ca9a2d774b2a53e7f4b93d285cba586ac3
53 changes: 53 additions & 0 deletions upload.py
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()
"""
2 changes: 2 additions & 0 deletions upload.sh
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

0 comments on commit 7deddca

Please sign in to comment.