How to serve an image using nodejs

前端 未结 11 1293
渐次进展
渐次进展 2020-11-22 08:18

I have a logo that is residing at the public/images/logo.gif. Here is my nodejs code.

http.createServer(function(req, res){
  res.writeHead(200,          


        
11条回答
  •  遇见更好的自我
    2020-11-22 09:09

    //This method involves directly integrating HTML Code in the res.write
    //first time posting to stack ...pls be kind
    
    const express = require('express');
    const app = express();
    const https = require('https');
    
    app.get("/",function(res,res){
        res.write("");
        res.send();
    });
    
    app.listen(3000, function(req, res) {
      console.log("the server is onnnn");
    });

提交回复
热议问题