简体   繁体   中英

CSS File not loading for HTML/Node.js server

I am making a url shortener called "Shrimp". Currently, here is my Node.JS:

 const express = require('express'); const app = express(); app.get('/', (req, res) => { res.sendFile(__dirname + '/index.html') }); app.listen(3000, () => { console.log('server started'); });

And my HTML:

 <!DOCTYPE html> <html lang="en"> <head> <link rel="stylesheet" href="/style.css"> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Shrimp</title> </head> <body> <h1>Shrimp</h1> <p>URL Shortener</p> <br> <form action=""> <input type="text" id="url" placeholder="URL to shorten" required> <input type="text" id="key" placeholder="Key (Optional)"> <button type="submit">Submit</button> </form> </body> </html>

Pretty simple, but the CSS is not loading! Can anybody help?

I am making a url shortener called "Shrimp". Currently, here is my Node.JS:

 const express = require('express'); const app = express(); app.get('/', (req, res) => { res.sendFile(__dirname + '/index.html') }); app.listen(3000, () => { console.log('server started'); });

And my HTML:

 <!DOCTYPE html> <html lang="en"> <head> <link rel="stylesheet" href="/style.css"> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Shrimp</title> </head> <body> <h1>Shrimp</h1> <p>URL Shortener</p> <br> <form action=""> <input type="text" id="url" placeholder="URL to shorten" required> <input type="text" id="key" placeholder="Key (Optional)"> <button type="submit">Submit</button> </form> </body> </html>

Pretty simple, but the CSS is not loading! Can anybody help?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM