A quickstart to emulating a webserver on your local machine. ** If you're familiar with Django, you can use Django's webserver to handle serving the needed items for Angular.
-
Install Homebrew:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
-
Install (or upgrade) Ruby:
brew install ruby
Windows: Here
-
Install Bundler
sudo gem install bundler
-
Create a
Gemfile
inside your project and put:source 'https://rubygems.org' gem 'rack'
-
Run & Install
bundle install
-
Create a file called
config.ru
on the same level as yoursrc
folder. Which is what contians your static files (js
,css
, andimages
directory) as well as yourindex.html
file. Inside theconfig.ru
file, add:use Rack::Static, :urls => ["/images", "/js", "/css", "/templates"], :root => "src" run lambda { |env| [ 200, { 'Content-Type' => 'text/html', 'Cache-Control' => 'public, max-age=86400' }, File.open('src/index.html', File::RDONLY) ] }
-
Run
rackup
in Terminal/Command Prompt. -
Navigate to http://127.0.0.1:9292/ or http://localhost:9292/