nodejs css cotent tipe

To set the content type for a CSS file in Node.js, you can follow the steps below:

  1. First, import the http module, which provides functionality to create an HTTP server in Node.js:
const http = require('http');
  1. Create a server using the createServer method of the http module:
const server = http.createServer((req, res) => {
  // Server logic goes here
});
  1. Inside the server logic, use the writeHead method of the response object to set the content type header to "text/css":
res.writeHead(200, { 'Content-Type': 'text/css' });
  1. Finally, use the end method of the response object to send the response back to the client:
res.end('CSS content goes here');

Here is the complete code snippet for setting the content type for a CSS file in Node.js:

const http = require('http');

const server = http.createServer((req, res) => {
  res.writeHead(200, { 'Content-Type': 'text/css' });
  res.end('CSS content goes here');
});

server.listen(3000, () => {
  console.log('Server is running on port 3000');
});

Please note that you need to replace 'CSS content goes here' with the actual content of your CSS file.