Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

use path.existsSync in place of statSync

  • Loading branch information...
commit 5def6df39bad2789e8904de09ce0103488a39c2f 1 parent 0328be2
@sandy98 authored
View
4 src/router.coffee
@@ -122,8 +122,8 @@ Router = (options = {}) ->
for home_page in dispatch.default_home
full_path = "#{dispatch.static_route}/#{home_page}"
try
- fs.statSync full_path
- return dispatch.static "/#{home_page}", res
+ if path_tools.existsSync full_path
+ return dispatch.static "/#{home_page}", res
catch error
dispatch.log error.toString() unless not dispatch.logging
if dispatch.list_dir
View
22 test/guaycuru.coffee
@@ -1,22 +0,0 @@
-#!/usr/bin/env coffee
-
-Router = require './router'
-http = require 'http'
-
-router = Router({static_route: process.cwd(), served_by: "Guaycuru Web Server", version: '0.0.1'})
-router.log "Working directory: #{router.static_route}"
-
-server = http.createServer router
-argv = process.argv.slice 2
-server.listen if argv[0]? and not isNaN(parseInt(argv[0])) then parseInt(argv[0]) else 8000
-
-addr = server?.address() or {address: '0.0.0.0', port: argv[0] or 8000}
-
-router.log "Serving web content at #{addr.address}:#{addr.port}"
-
-process.on "SIGINT", ->
- server.close()
- router.log "\n Server shutting up...\n"
- process.exit 0
-
-
View
BIN  test/public/favicon.ico
Binary file not shown
View
8 test/router.coffee
@@ -122,8 +122,8 @@ Router = (options = {}) ->
for home_page in dispatch.default_home
full_path = "#{dispatch.static_route}/#{home_page}"
try
- fs.statSync full_path
- return dispatch.static "/#{home_page}", res
+ if path_tools.existsSync full_path
+ return dispatch.static "/#{home_page}", res
catch error
dispatch.log error.toString() unless not dispatch.logging
if dispatch.list_dir
@@ -257,7 +257,7 @@ Router = (options = {}) ->
res.writeHead(404, {'Content-Type': 'text/html'})
res.end("""
<h2>404 - Resource #{path} not found at this server</h2>
- <hr/><h3>Node Simple Router v#{dispatch.version}</h3>
+ <hr/><h3>Served by #{dispatch.served_by} v#{dispatch.version}</h3>
<p style="text-align: center;"><button onclick='history.back();'>Back</button></p>
""")
@@ -265,7 +265,7 @@ Router = (options = {}) ->
res.writeHead(405, {'Content-Type': 'text/html'})
res.end("""
<h2>405 - Resource #{path}: #{message}</h2>
- <hr/><h3>Node Simple Router v#{dispatch.version}</h3>
+ <hr/><h3>Served by #{dispatch.served_by} v#{dispatch.version}</h3>
<p style="text-align: center;"><button onclick='history.back();'>Back</button></p>
""")
Please sign in to comment.
Something went wrong with that request. Please try again.