【问题标题】:How to open a local html file, not with file:// but with a web server like http://localhost:8080/VideoUsingWebComponents/index.html如何打开本地 html 文件,而不是使用 file://,而是使用诸如 http://localhost:8080/VideoUsingWebComponents/index.html 之类的 Web 服务器
【发布时间】:2017-11-01 02:47:48
【问题描述】:

I am not able to follow this .png file,posted for your reference

我有一个压缩文件提取到以下位置,C:\Program Files\WAMP\ht docs\VideoUsingWebComponents,根据上传的图像文件创建在这里。在我应该打开 index.html 文件的文件夹中一个网络服务器,只需单击 html 文件,浏览器就会打开 file:///C:/Program%20Files/WAMP/ht%20docs/VideoUsingWebComponents/index.html, 我希望它以上传图片中指示的http://localhost:8080...as 打开,所以我尝试像这样更改上面的链接, http://localhost:8080/C:/Program%20Files/WAMP/ht%20docs/VideoUsingWebComponents/index.html,但 localhost 拒绝连接。 我使用的是 windows pc,此处显示的图像是 Mac。请帮助使用 Web 服务器打开 index.html 文件。 谢谢

【问题讨论】:

  • 请更好地格式化您的问题。这令人困惑。您是否安装了网络服务器?除非您正在运行 Web 服务器,否则您将无法访问 localhost:8080

标签: html web server localhost


【解决方案1】:

localhost:8080 是您计算机上运行的任何服务器使用的端口。

但通常你需要自己安装这样的服务器。

Mozilla 有一篇文章详细解释了一切 - https://developer.mozilla.org/en-US/docs/Learn/Common_questions/set_up_a_local_testing_server

这家伙以更简单的方式解释了如何在所有平台上安装服务器,只需滚动到 Windows 部分 - https://www.maketecheasier.com/setup-local-web-server-all-platforms/

希望这两个链接对您有所帮助!

【讨论】:

  • 谢谢 nishkaush,从来不知道这样的事!!
【解决方案2】:

Python 带有一个可以直接调用的内置服务器:

python -m SimpleHTTPServer 

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-09-06
    • 2014-09-26
    • 2012-06-24
    • 1970-01-01
    • 1970-01-01
    • 2016-07-02
    • 1970-01-01
    相关资源
    最近更新 更多