Using JavaScript, if it is a static page, Chrome AJAX request local files often problems.
XMLHttpRequest cannot load
file:///*******.
Origin null is not allowed by Access-Control-Allow-Origin.
Because Chrome security mechanisms do not allow AJAX to load local files.
So, I decide to use a new method with ruby.
- Install the rack, and set rack profiles config.ru:
gem install rack
echo "run Rack::Directory.new('')" > ~/config.ru
- Switch to any directory and run:
rackup ~/config.ru
If you think the command so long, establish alias alias rp='rackup ~/config.ru'
The default boot server port is 9292,-p [port_num]
can modify the port number, now open the browser to get the current directory of the file list: http://locahost:9292/