Serving Static Files with HTTP-Server šŸŒ

Serving Static Files with HTTP-Server šŸŒ
http-server is an easy-to-use, zero-configuration command-line HTTP server for serving static files during project development.

šŸ’» To get started:

1. Install http-server globally:  
Run this command in your terminal:  
<pre class="preFormatted"><code class="codeFormatted">
npm install -g http-server
</code></pre>

2. Run the server without caching:  
Disable caching to see file changes immediately by running:  
<pre class="preFormatted"><code class="codeFormatted">
http-server -c-1
</code></pre>

3. Open your browser and navigate to:  
<pre class="preFormatted"><code class="codeFormatted">
localhost:8080
</code></pre>

4. To quit the server, use:  
Press `Ctrl + C` in your terminal to stop the server.

šŸ” Note:  
Disabling caching is great for development because it ensures that any changes you make to your static files are immediately reflected in the browser, without the interference of cached versions.

Published: April 2024

ā† Back to Blog