学习搭建服务器可用postman 连接不了localhost的端口

网上好多教程是这样连接

看完视频后我们是这样

找了大量资料都解决不了,什么版本,什么证书的都不好使,最简单的就是去掉http://

  1. //get 测试
  2.  
  3. const http=require('http')
  4. const querystring=require('querystring')
  5.  
  6. const server=http.createServer((req, res)=>{
  7.  
  8. //GET
  9. console.log('method',req.method)
  10. const url=req.url
  11. // /
  12. console.log('url:',url)
  13. req.query=querystring.parse(url.split('?')[])
  14. console.log('query:',req.query)
  15.  
  16. res.end(
  17. JSON.stringify(req.query)
  18. )
  19.  
  20. })
  21.  
  22. server.listen()
  23. console.log('测试get')

node get

  1. const http=require('http')
  2. const server=http.createServer((req, res) =>{
  3. if(req.method==='POST'){
  4.  
  5. console.log('content-type',req.headers['content-type'])
  6.  
  7. let postData=""
  8. req.on('data',chunk=>{
  9. postData+=chunk.toString()
  10. })
  11. req.on('end',()=>{
  12. console.log(postData)
  13. res.end('post请求执行结束')
  14. })
  15. }
  16. })
  17. server.listen();
  18. console.log('post请求执行开始')

node post

测试代码

postman连接不了localhost问题解决的更多相关文章

  1. SQLServerException:通过端口 1433 连接到主机 localhost 的 TCP/IP 连接失败。

    一.问题描述: 1.连接数据库时抛出的异常: com.microsoft.sqlserver.jdbc.SQLServerException: 通过端口 1433 连接到主机 localhost 的 ...

  2. postman连接mysql执行操作

    postman也可以连接mysql 目录 1.安装 2.启动服务 3.执行sql语句 1.安装 想要postman连接mysql,需要安装xmysql,启动该服务,然后才可以调用. 预置条件:完成no ...

  3. 【转】Java JDBC连接SQL Server2005错误:通过端口 1433 连接到主机 localhost 的 TCP/IP 连接失败

    错误原因如下: Exception in thread "main" org.hibernate.exception.JDBCConnectionException: Cannot ...

  4. Java JDBC连接SQL Server2005错误:通过port 1433 连接到主机 localhost 的 TCP/IP 连接失败

    错误原因例如以下: Exception in thread "main" org.hibernate.exception.JDBCConnectionException: Cann ...

  5. Java JDBC连接SQL Server2005错误:通过端口 1433 连接到主机 localhost 的 TCP/IP 连接失败 及sql2008外围服务器

    转载:Java JDBC连接SQL Server2005错误:通过端口 1433 连接到主机 localhost 的 TCP/IP 连接失败 错误原因如下: Exception in thread & ...

  6. mysql Access denied for user 'root'@'localhost'问题解决

    问题描述: 系统安装mysql的过程中,没有提示配置用户名和密码相关的信息,安装完毕后,登录报错. 表现现象为: mysql -u root -p [输入root密码] 界面提示: ERROR 169 ...

  7. orcal数据库得连接必须用localhost,url中不要用127.0.0.1,不然无法连接

    orcal数据库得连接必须用localhost,url中不要用127.0.0.1,不然无法连接,

  8. Can't connect to MySQL server on 'localhost' (10061),连接Navicat报错问题解决

    今天,装了Mysql 1.1.7后,连接Navicat 时报错,后来找了一阵,发现问题所在. 原因是我在安装时把默认端口号3306修改成了3303, 连接时,把默认端口也修改下就好啦.

  9. Redis安装以及Java客户端jedis连接不上相关问题解决

    安装步骤 1.由于Redis是由C 语言编写的 所以虚拟机编译需要C的编译环境 用命令 yum install gcc-c++ 2.用SFTP上传Redis安装包并解压 3.进入Redis源码目录 b ...

随机推荐

  1. 集合 HashMap 的原理,与 Hashtable、ConcurrentHashMap 的区别

    一.HashMap 的原理 1.HashMap简介 简单来讲,HashMap底层是由数组+链表的形式实现,数组是HashMap的主体,链表则是主要为了解决哈希冲突而存在的,如果定位到的数组位置不含链表 ...

  2. selenium3与Python3实战 web自动化测试框架✍✍✍

    selenium3与Python3实战 web自动化测试框架  整个课程都看完了,这个课程的分享可以往下看,下面有链接,之前做java开发也做了一些年头,也分享下自己看这个视频的感受,单论单个知识点课 ...

  3. 伪类checked

    困惑了好久的复选框自定义样式终于有了谜底,原来就是一个 :checked 伪类 他的意思就是 匹配任意被勾选/选中的radio(单选按钮),chexked(复选框),或者option(select项) ...

  4. 用selenium 自动爬取某一本小说章节及其内容,并存入数据库中

    from selenium import webdriver import pymysql from selenium.webdriver.support.ui import WebDriverWai ...

  5. nodejs 模板引擎ejs的简单使用(3)

    1.ejs <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <tit ...

  6. vue computed和methods 计算属性和侦听器

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  7. Redis探索之路(六):Redis的常用命令

    一:键值相关命令 1.keys Pattern模糊查询 keys my* 2.exists某个key是否存在 exists key1 3.del 删除一个key del key1 4.expire设置 ...

  8. Python自学:第四章 遍历切片

    # -*- coding: GBK -*- players = ['charles', 'martina', 'michael', 'florence', 'eli'] print("Her ...

  9. GlobalExceptionHandler 捕获抛出的异常,返回特定值给前端

    /** * @author hhh * @date 2019/1/17 16:28 * @Despriction */ @ResponseBody @ControllerAdvice @Log4j2 ...

  10. Java中的线程Thread方法之---interrupt()

    前几篇都介绍了Thread中的几个方法,相信大家都发现一个相似点,那就是sleep,join,wait这样的阻塞方法都必须捕获一个InterruptedException异常,顾名思义就是一个线程中断 ...