Help us understand the problem. What is going on with this article?

Ruby Simple HTTP Server With Rack

More than 5 years have passed since last update.

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/

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした