-
Notifications
You must be signed in to change notification settings - Fork 0
/
GeckoServer.coffee
27 lines (23 loc) · 985 Bytes
/
GeckoServer.coffee
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
page = require("webpage").create() # spin up a web page
webserverTest = require("webserver").create() # http://docs.slimerjs.org/current/api/webserver.html
webserverTest.listen 8083, (request, response) ->
if request.url is "/ping.html"
response.statusCode = 200
response.write "slimerjs server is listening\n"
response.close()
else
# ../ does not work on the beginning position, so replace with direct link
page.open("../local-copies/html-converted/" + request.queryString + "/" + request.queryString + ".html").then (status) ->
if status is "success"
console.log request.queryString
console.log request.path
response.statusCode = 200
response.write "page loaded by slimerjs"
response.close()
else
response.statusCode = 500
response.write "page could not be found by slimerjs"
response.close()
console.log "page could not be found by slimerjs"
page.close()
#...