最简单的方式来承载HTML [英] Simplest way to host html

查看:194
本文介绍了最简单的方式来承载HTML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通过局域网托管一个HTML页面的最简单方法是什么?



我的字面上只需要有5行HTML,所以我不想下载并安装Apache服务器。我只想知道在Windows上做到这一点的最快/最简单的方法,或者如果速度更快,我也可以使用我的一个Linux虚拟机。 / div>由于您需要一个Web服务器进行测试,并且预计不会有重复的并发使用,所以我会保持简单。



请注意这两种解决方案都非常简单但并不十分安全,将它们用于开发目的,但不要将它们都不依赖任何与稳定程序几乎相似的东西(人们会说生产)服务器



使用 cmd.exe 导航到HTML文件所在的目录,然后执行:



使用Python



  python -m SimpleHTTPServer 
pre>

HTTP服务器将在端口8000上启动。如果您需要不同的端口,只需指定它:

  python -m SimpleHTTPServer 8080 

SimpleHTTPServer 是包含电池的一部分:当然,除了Python解释器之外,您不需要安装任何额外的软件包。

Python已经安装在大多数Linux发行版上,因此切换到Linux可能比在Windows上安装Python更简单,但这归结于下载和运行安装程序。或以上

  php -S 0.0.0.0:8080 

这也会处理PHP脚本,但HTML资源将会正常投放。


What is the simplest way to host an HTML page over LAN?

I literally just need to have like 5 lines of HTML, so I don't want to download and setup an Apache server. I just want to know the fastest/simplest way to do this on Windows, or I can also use one of my Linux virtual machines if it's faster.

解决方案

Since you need a web server for testing and no heavy concurrent use is expected, I'll just keep it simple.

Please note that both solutions are very simple but not very secure, use them for development purposes but don't rely on neither of them for anything barely similar to a stable (people would say "production") server.

Navigate to the directory where your HTML file is located using cmd.exe, then issue:

Using Python

python -m SimpleHTTPServer

A HTTP server will be started on port 8000. Should you need a different port, just specify it:

python -m SimpleHTTPServer 8080

SimpleHTTPServer is part of the "batteries included": you will not need to install any extra package, apart from the Python interpreter, of course.

Python comes already installed on most Linux distributions, so switching to Linux might be simpler than install Python on Windows, although that boils down to downloading and running an installer.

Using PHP 5.4 or above

php -S 0.0.0.0:8080

This will also process PHP scripts, but HTML resources will be served fine.

这篇关于最简单的方式来承载HTML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆