Ravi Vishwakarma is a dedicated Software Developer with a passion for crafting efficient and innovative solutions. With a keen eye for detail and years of experience, he excels in developing robust software systems that meet client needs. His expertise spans across multiple programming languages and technologies, making him a valuable asset in any software development project.
Ravi Vishwakarma
04-Apr-2025You can serve static files (like HTML, CSS, JS, images, etc.) in Express using the built-in middleware
express.static
.Basic Setup:
Example Folder Structure:
With this setup:
http://localhost:3000/index.html
serves theindex.html
file.http://localhost:3000/style.css
serves the CSS file, etc.You can also mount it at a specific route:
Now your files will be accessible like:
http://localhost:3000/static/index.html
Also Read: How do you define a route in Express?