zoukankan      html  css  js  c++  java
  • [Express 5] Create a express 5 application with node 14

    In this lesson we'll build a basic web server in 2 minutes using Express 5 and node 14's native ES module support.

    We'll start by creating a new project using npm init and then add "type": "module" to our package.json file to opt-in to ES Module support.

    From there we'll create an index.js file where we create an instance of the express module and add a single GET route that sends the response "hello". Finally we listen on port 3000 and confirm that our route responds to requests using both curl and a web browser.

    import express from "express";
    
    const app = express();
    
    app.get("/", function (req, res) {
      res.send("hello");
    });
    
    app.listen(3000);

    Running:

    node index.js

    See localhost:3000 to see the message from the browser.

  • 相关阅读:
    浏览器版本过低
    虚拟PWN初探
    elasticsearch常用查询
    python安装pip模块
    spark-kafka-es交互 优化
    scala写文件
    python unittest
    scala collection(集合)
    spark-kafka-es交互
    scala语法
  • 原文地址:https://www.cnblogs.com/Answer1215/p/13387670.html
Copyright © 2011-2022 走看看