0
点赞
收藏
分享

微信扫一扫

JavaScript服务器环境运行步骤


  1. 安装node环境
    cmd下输入 node -v有版本号就说明已经安装成功了
    C:\Users\HP>node -v
    v10.16.3
  2. 切换到要运行服务器文件夹里面,文件夹名称和文件夹路径最好都设置为英文,中文会出错
    C:\Users\HP>D:
    D:>CD D:\PyProject\Web_front_end_study\09_jQuery_Server
    D:\PyProject\Web_front_end_study\09_jQuery_Server>
  3. 将服务器js文件(server.js)(网上直接下载)放置在文件中
  4. 创建一个index.html文件用于测试
  5. 启动服务器环境
    D:\PyProject\Web_front_end_study\09_jQuery_Server>node server.js
    Static file server running at
    => http://localhost:8888/
    CTRL + C to shutdown
  6. 浏览器打开http://localhost:8888/
    会自动打开文件中的index.html文件
    浏览器打开显示:js服务器环境测试
    cmd窗口中显示:
    200: D:\PyProject\Web_front_end_study\09_jQuery_Server/index.html as text/html
    404: D:\PyProject\Web_front_end_study\09_jQuery_Server\favicon.ico
  • 以上步骤成功进行,说明服务器环境启动成功
  • ​​http://localhost:8888/默认打开的是文件夹里面的index.html​​​ 如果没有就报404 not found
    我们如果需要打开文件夹里面其它的HTML文件
    直接在后面加一个斜线,然后接着写文件名即可,比如:
    http://localhost:8888/004cookietest.html
    注意:服务器环境下打开的HTML文件,文件名最好是全英文
    带数字也可以,但是如果名称中有汉字或者下划线等特殊符号,打开时候后报404错误


举报

相关推荐

0 条评论