当前位置:网站首页>Simple use of express web server
Simple use of express web server
2022-07-27 21:14:00 【Xiaomenong】
// introduce express
const express=require("express");
// Create a express The server
const app=express();
// Set the path and method of the request , Execute the callback function after the request succeeds
app.get('/server',(request,response)=>{
// Set the response header , To solve the cross domain
response.setHeader('Access-Control-Allow-Origin','*')
// Set the response body
response.send("hhhh")
})
// Start the service
app.listen(9000,()=>{
console.log(" The server has started , port 9000 Monitoring ....")
})Sending AJAX When setting url Parameter method
app.get('/server',(request,response)=>{})
// Set parameters in the address bar
// stay server Pass it with a question mark later Multiple parameters with & separate in the light of AJAX Sending requests will cause cache problems
We put a timestamp after the requested path for example '127.0.0.1:8080/server?t='+Data.now()
About AJAX request timeout , We need to set a timeout on the front end
// The timeout is set to 2s, Is if you ask 2s Not yet requested , Just cancel the request
xhr.timeout=2000
// We can also set a callback for request timeout
xhr.ontimeout=function(){}
// Callback of network exception
xhr.οnerrοr=function(){}
边栏推荐
- Typoa spelling check: missing dictionary file for Chinese
- Knife4j dynamically refreshes global parameters through JS
- Differences among native objects, built-in objects, and host objects
- LeetCode每日一练 —— 链表中倒数第 k 个结点
- 论文赏析[AAAI18]面向序列建模的元多任务学习
- 【历史上的今天】7 月 27 日:模型检测先驱出生;微软收购 QDOS;第一张激光照排的中文报纸
- sscanf 导致地址越界
- CPDA | how to have data analysis thinking?
- 如何查看蓝牙耳机的蓝牙版本
- R language uses LM function to build multiple linear regression model, writes regression equation according to model coefficient, and uses deviance function to calculate the sum of squares of residual
猜你喜欢

What if the start button doesn't respond after the win11 system updates kb5014668?

Installation and use tutorial of the latest version of Web vulnerability scanning tool appscan\awvs\xray

82. (cesium article) cesium points move on 3D models

Automated testing ----- selenium (II)

Leetcode-209- subarray with the smallest length

A lock faster than read-write lock. Don't get to know it quickly

PHP code audit 6 - file contains vulnerability

Win11 widget prompts how to solve the error when loading this content?

如何让个性化推荐即刻触达?云原生数据库GaussDB(for Redis)来助力

MAPGIS 3D pipeline modeling awakens the pulse of urban underground pipelines
随机推荐
sscanf 导致地址越界
Hexagon_ V65_ Programmers_ Reference_ Manual(7)
MAPGIS 3D scene rendering technology and Application
Leetcode-209- subarray with the smallest length
原生对象、内置对象、宿主对象的区别
Zhongdi Digital: integrating innovative domestic GIS to boost the construction of real 3D China
PG 之 Free Space Map & Visibility Map
Leetcode daily practice - cm11 linked list segmentation
The dplyr package of R language performs aggregation transformations of data packets and calculates the sum of packets of dataframe data
MAPGIS 3D pipeline modeling awakens the pulse of urban underground pipelines
Sscanf caused the address to be out of bounds
搭建discuz论坛并攻破盗取数据库
【历史上的今天】7 月 27 日:模型检测先驱出生;微软收购 QDOS;第一张激光照排的中文报纸
Chapter 7 Intermediate Shell Tool I
Understand the encapsulation and de encapsulation of network model data
【R语言】【1】初学R语言语法使用Rstudio编辑
怎样实现文档协同?
Typoa spelling check: missing dictionary file for Chinese
Automated testing - unittest framework
Codeforces 1706E 并查集 + 启发式合并 + ST 表