代码之家  ›  专栏  ›  技术社区  ›  Milano

http。服务器(SimpleHTTPServer)服务文件。html而不是dir(使用cmd)

  •  0
  • Milano  · 技术社区  · 4 年前

    是否可以不提供目录索引,而是提供 html SimpleHTTPServer 在路上 '/' ?

    有一个文件的目录 login.html '/' .

    python -m SimpleHTTPServer 7800
    

    screenshot

    我想要一份 在…上 '/' .

    可能吗?

    2 回复  |  直到 4 年前
        1
  •  2
  •   match    4 年前

    SimpleHTTPServer (或 http.server 在Python3中)将提供一个目录 除非 index.html

    那就改名吧 login.html 指数html

        2
  •  1
  •   abhijith n raj    4 年前

    默认情况下,http服务器查找索引。html文件并加载它。否则它将服务于目录结构。

    但也可以在索引中添加重定向。html。

    <html>
    <body>
        <!-- redirect on load -->
        <script>
            window.onload = function () {
                window.location.href = "login.html";
            }
        </script>
    </body>
    </html>