summaryrefslogtreecommitdiff
path: root/hw6
diff options
context:
space:
mode:
authorAlexander Pickering <alex@cogarr.net>2020-01-01 22:37:37 -0500
committerAlexander Pickering <alex@cogarr.net>2020-01-01 22:37:37 -0500
commit9fae5d516012e2c0802105e67c79e2587a22b9dc (patch)
tree1c782ad2cd08bd1ecc4f0b42bd042778b4f34c2e /hw6
downloadinfsci2620-master.tar.gz
infsci2620-master.tar.bz2
infsci2620-master.zip
Inital commitHEADmaster
Diffstat (limited to 'hw6')
-rw-r--r--hw6/2620.HW06.API.docxbin0 -> 442550 bytes
-rw-r--r--hw6/app.moon43
-rw-r--r--hw6/hw5.moon24
-rw-r--r--hw6/hw6.zipbin0 -> 443711 bytes
-rw-r--r--hw6/res/1.PNGbin0 -> 263080 bytes
-rw-r--r--hw6/res/2.PNGbin0 -> 156969 bytes
-rw-r--r--hw6/res/3.PNGbin0 -> 150388 bytes
7 files changed, 67 insertions, 0 deletions
diff --git a/hw6/2620.HW06.API.docx b/hw6/2620.HW06.API.docx
new file mode 100644
index 0000000..aaa2306
--- /dev/null
+++ b/hw6/2620.HW06.API.docx
Binary files differ
diff --git a/hw6/app.moon b/hw6/app.moon
new file mode 100644
index 0000000..98b15b7
--- /dev/null
+++ b/hw6/app.moon
@@ -0,0 +1,43 @@
+--Alexander Pickering (amp215@pitt.edu)
+--
+-- More moonscript!
+-- $ luarocks install xavante
+-- $ moon app.lua
+
+web = require("xavante")
+hw5 = require("hw5")
+
+pages = {}
+add_page = (pat, fun) -> table.insert(pages, {match: pat, with: fun})
+
+hello = (req, res, indexname) ->
+ res.content = "<html><h1>Hello, world!</h1></html>"
+ res
+
+add_page("^/$",hello)
+
+decode_entity = (s) ->
+ --decode the number using base 16, then convert the number to a string
+ string.char(tonumber(s,16))
+
+proper = (req, res, indexname) ->
+ query = req.parsed_url.query
+ --Decode the %20 entties in the string
+ decoded = string.gsub(query,"%%(%d+)",decode_entity)
+ mixed = hw5(decoded)
+ --Poor man's json
+ quoted = [string.format("%q",word) for word in *mixed]
+ res.content = "[" .. table.concat(quoted,",") .. "]"
+ res
+
+add_page("^/proper$",proper)
+
+config = {}
+config.server =
+ host: "*"
+ port: 8080
+
+config.defaultHost = {rules: pages}
+
+web.HTTP(config)
+web.start!
diff --git a/hw6/hw5.moon b/hw6/hw5.moon
new file mode 100644
index 0000000..568bf9d
--- /dev/null
+++ b/hw6/hw5.moon
@@ -0,0 +1,24 @@
+
+accept_input = io.read
+
+split_string = (s) -> [x for x in string.gmatch(s,"(%S+)")]
+
+capitalize_word = (word) -> string.gsub(word,"^(.)",string.upper)
+
+uppercase_words = (array) ->
+ [capitalize_word(word) for word in *array]
+
+print_words = (array) ->
+ for word in *array do
+ print(word)
+
+sort_words = table.sort
+
+apply_caps = (str) ->
+ words = split_string(str)
+ words = uppercase_words(words)
+ sort_words(words)
+ words
+
+--return the apply_caps() function when we require()
+apply_caps
diff --git a/hw6/hw6.zip b/hw6/hw6.zip
new file mode 100644
index 0000000..e437715
--- /dev/null
+++ b/hw6/hw6.zip
Binary files differ
diff --git a/hw6/res/1.PNG b/hw6/res/1.PNG
new file mode 100644
index 0000000..1edfedd
--- /dev/null
+++ b/hw6/res/1.PNG
Binary files differ
diff --git a/hw6/res/2.PNG b/hw6/res/2.PNG
new file mode 100644
index 0000000..af4590f
--- /dev/null
+++ b/hw6/res/2.PNG
Binary files differ
diff --git a/hw6/res/3.PNG b/hw6/res/3.PNG
new file mode 100644
index 0000000..1ddbf85
--- /dev/null
+++ b/hw6/res/3.PNG
Binary files differ