[html] Failed to load resource: the server responded with a status of 404 (Not Found) css

I'm having trouble getting my browser to display the css for the app I am creating. I have looked at the same question asked by other users but have not found any of the answers to help in my situation. When I goto the page, all that is displayed is "Hello world" with no styling even though the stylesheet is linked. When I inspect the page, I get the error:

Failed to load resource: the server responded with a status of 404 (Not Found)

here's the structure of my application

.
./public 
     /css
       /main.css
./routes
     /index.js
./views
     /index.html
./server.js

server.js:

const express = require('express');
const app = express();
const port = process.env.PORT || 8080;

app.use(express.static(__dirname + '/public')); 
const router = require('./routes/index.js');
app.use('/',router);

app.listen(port);

console.log('connected to port: ' + port);

index.html

<!DOCTYPE html>
<html>
<head>
<link href="../public/css/main.css" rel="stylesheet">
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>

</head>
 <body>
    <p>Hello World!</p>
 </body>

index.js

var express = require('express');
var path = require('path');
var router = express.Router();
module.exports = router;

router.get('/', function(req,res){
res.sendFile(path.join(__dirname,'../views/index.html'));
});

This question is related to html css api

The answer is


Use the following Code:-

../css/main.css

Note: The "../" is shorthand for "The containing directory", or "Up one directory".

If you don't know the previous folder this will be very helpful..


i use firebase-database in html signup but last error i cannot understand if anybody know tell me . error is "Failed to load resource: the server responded with a status of 404 ()"


Questions with html tag:

Embed ruby within URL : Middleman Blog Please help me convert this script to a simple image slider Generating a list of pages (not posts) without the index file Why there is this "clear" class before footer? Is it possible to change the content HTML5 alert messages? Getting all files in directory with ajax DevTools failed to load SourceMap: Could not load content for chrome-extension How to set width of mat-table column in angular? How to open a link in new tab using angular? ERROR Error: Uncaught (in promise), Cannot match any routes. URL Segment Angular 6: saving data to local storage Vue.js get selected option on @change Bootstrap 4 multiselect dropdown How to add bootstrap in angular 6 project? Angular 5 Button Submit On Enter Key Press Angular 5, HTML, boolean on checkbox is checked How to render string with html tags in Angular 4+? bootstrap 4 file input doesn't show the file name How can I execute a python script from an html button? Bootstrap 4: responsive sidebar menu to top navbar Stylesheet not loaded because of MIME-type Force flex item to span full row width Failed to load resource: the server responded with a status of 404 (Not Found) css Change arrow colors in Bootstraps carousel Bootstrap 4 Dropdown Menu not working? CSS Grid Layout not working in IE11 even with prefixes How to prevent page from reloading after form submit - JQuery Centering in CSS Grid Detecting real time window size changes in Angular 4 Angular 4 img src is not found (change) vs (ngModelChange) in angular Bootstrap 4: Multilevel Dropdown Inside Navigation Align the form to the center in Bootstrap 4 How to style a clicked button in CSS How do I change the font color in an html table? Redirecting to a page after submitting form in HTML Load json from local file with http.get() in angular 2 display: flex not working on Internet Explorer Scroll to element on click in Angular 4 How to extract svg as file from web page force css grid container to fill full screen of device How does the "position: sticky;" property work? HTML5 Video autoplay on iPhone Disable button in angular with two conditions? CSS hide scroll bar, but have element scrollable CSS grid wrapping How to load image (and other assets) in Angular an project? Flask - Calling python function on button OnClick event How can I make Bootstrap 4 columns all the same height? Wrapping a react-router Link in an html button

Questions with css tag:

need to add a class to an element Using Lato fonts in my css (@font-face) Please help me convert this script to a simple image slider Why there is this "clear" class before footer? How to set width of mat-table column in angular? Center content vertically on Vuetify bootstrap 4 file input doesn't show the file name Bootstrap 4: responsive sidebar menu to top navbar Stylesheet not loaded because of MIME-type Force flex item to span full row width Font Awesome 5 font-family issue Failed to load resource: the server responded with a status of 404 (Not Found) css CSS class for pointer cursor How and where to use ::ng-deep? Styling mat-select in Angular Material What is the difference between CSS and SCSS? iPhone X / 8 / 8 Plus CSS media queries Change arrow colors in Bootstraps carousel Bootstrap 4 Dropdown Menu not working? Add class to an element in Angular 4 CSS Grid Layout not working in IE11 even with prefixes Search input with an icon Bootstrap 4 Bootstrap 4 - Inline List? Centering in CSS Grid Bootstrap 4, how to make a col have a height of 100%? Equal height rows in CSS Grid Layout Bootstrap 4: Multilevel Dropdown Inside Navigation Align the form to the center in Bootstrap 4 Customize Bootstrap checkboxes How to style a clicked button in CSS How can I get the height of an element using css only display: flex not working on Internet Explorer force css grid container to fill full screen of device How does the "position: sticky;" property work? bootstrap 4 row height Prevent content from expanding grid items Bootstrap 4 File Input CSS hide scroll bar, but have element scrollable CSS grid wrapping Bootstrap 4 Change Hamburger Toggler Color How can I make Bootstrap 4 columns all the same height? How to hide collapsible Bootstrap 4 navbar on click Bootstrap 4 Center Vertical and Horizontal Alignment Cannot read property 'style' of undefined -- Uncaught Type Error How to window.scrollTo() with a smooth effect Vertical Align Center in Bootstrap 4 How to implement a Navbar Dropdown Hover in Bootstrap v4? CSS change button style after click What is correct media query for IPad Pro? How do I specify row heights in CSS Grid layout?

Questions with api tag:

I am receiving warning in Facebook Application using PHP SDK Couldn't process file resx due to its being in the Internet or Restricted zone or having the mark of the web on the file Failed to load resource: the server responded with a status of 404 (Not Found) css Call another rest api from my server in Spring-Boot How to send custom headers with requests in Swagger UI? This page didn't load Google Maps correctly. See the JavaScript console for technical details How can I send a Firebase Cloud Messaging notification without use the Firebase Console? Allow Access-Control-Allow-Origin header using HTML5 fetch API How to send an HTTP request with a header parameter? Laravel 5.1 API Enable Cors What is the difference between resource and endpoint? App not setup: This app is still in development mode For Restful API, can GET method use json data? What exactly is the difference between Web API and REST API in MVC? REST API - Bulk Create or Update in single request How to use OAuth2RestTemplate? REST API error code 500 handling Make REST API call in Swift What is a callback URL in relation to an API? Parsing HTTP Response in Python What's the best way of scraping data from a website? Creating a REST API using PHP Has Facebook sharer.php changed to no longer accept detailed parameters? REST API using POST instead of GET curl posting with header application/x-www-form-urlencoded Parsing Json rest api response in C# How to send a correct authorization header for basic authentication How do I download a file using VBA (without Internet Explorer) Get a json via Http Request in NodeJS Catching exceptions from Guzzle The type List is not generic; it cannot be parameterized with arguments [HTTPClient] Making a request to a RESTful API using python WhatsApp API (java/python) How to use cURL to get jSON data and decode the data? JSONDecodeError: Expecting value: line 1 column 1 (char 0) Getting GET "?" variable in laravel Google Maps v2 - set both my location and zoom in REST API Login Pattern UEFA/FIFA scores API Free Rest API to retrieve current datetime as string (timezone irrelevant) Instagram API to fetch pictures with specific hashtags How to Logout of an Application Where I Used OAuth2 To Login With Google? Twitter API returns error 215, Bad Authentication Data Automated testing for REST Api cURL POST command line on WINDOWS RESTful service Using JSON POST Request How to parse freeform street/postal address out of text, and into components Instagram API: How to get all user media? How to make a custom LinkedIn share button How can a Jenkins user authentication details be "passed" to a script which uses Jenkins API to create jobs?