Javascript 使用http服务器找不到Angular JS页面

Javascript 使用http服务器找不到Angular JS页面,javascript,html,angularjs,httpserver,Javascript,Html,Angularjs,Httpserver,我有一个简单的angular应用程序,其目录结构如下所示: -lpbm -shared - js - css -public app.js index.html 我在lpbm文件夹中运行http服务器,该文件夹创建http://localhost:8080 然后我尝试访问http://localhost:8080/public/index.html但我在终端窗口中看到一个空白页和以下错误:错误“get/public/index.html”(404):“找不到” 这是工作

我有一个简单的angular应用程序,其目录结构如下所示:

-lpbm
 -shared
  - js
  - css
 -public
   app.js
   index.html
我在lpbm文件夹中运行http服务器,该文件夹创建
http://localhost:8080

然后我尝试访问
http://localhost:8080/public/index.html
但我在终端窗口中看到一个空白页和以下错误:
错误“get/public/index.html”(404):“找不到”

这是工作之前,和一些随机必须阻止它正常工作,因为目录和url结构是正确的。除了下面的index.htmlapp.js之外,我已尝试删除所有自定义文件

index.html:

<!doctype html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>Cheapest Fares</title>

    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="../shared/css/bootstrap-cerulean.css">
    <link rel="stylesheet" href="../shared/css/app.css">
    <link rel="stylesheet" href="../shared/css/lpbm.css">
    <script src="../shared/js/angular.js"></script>
    <script src="../shared/js/angular-messages.js"></script>
    <script src="../shared/js/angular-message-format.js"></script>
    <script src="../shared/js/angular-route.js"></script>
    <script src="../shared/js/angular-animate.js"></script>
    <script src="app.js"></script>
</head>
<body class="container" ng-app="app" ng-strict-di ng-controller="AppController as app">
    <h1>Our cheapest fares from London</h1>
    <div class="row">
        <ng-view autoscroll></ng-view>
    </div>
</body>
</html>

是否有任何明显的原因,这是不工作的?如果我打开一个测试angular应用程序,并执行它工作的相同http服务器进程,这表明我的app.js或index.html有问题,但我无法发现问题所在,我确实删除了所有内容,但它仍然拒绝加载

我已将您的代码移动到Plunker,并删除了其他依赖项,所有这些似乎都工作正常

我建议你也这样做。如果这不是问题,请尝试查看应用程序的服务器端。 还有错误

"GET /public/index.html" Error (404): "not found" 
你提到的可能暗示了这一点


Plunker链接:

http://localhost:8080/
而非
http://localhost:8080/public/
是因为您使用的是虚拟装载路径。例如,在像express这样的框架中,这是这样做的:

app.use('/',express.static('public')

这决定了服务器的哪些部分可以通过客户端访问。第一个参数('/')设置客户端导航到的位置,以便在第二个参数('public')中的位置访问文件。在将
/shared
文件夹放入
/public
目录之前,无法访问该文件夹的原因是该文件夹超出了向客户端公开的范围


如果您不使用express,代码看起来可能略有不同,但实际上就是这样。不知怎的,这行代码被取消注释或添加到您的服务器。

我无法在url“@arbit”中看到应用程序上下文,但您也应该可以,对吗?它在星期五工作。你的浏览器控制台打印:工作吗?问题是你的服务器代码。为什么要发布html和angular代码?html是404。这就是问题所在。尝试摆脱/public,只访问index.html。也许您直接将public作为http的根公开。@tpie我发布其他代码的原因是,当我在其他文件夹中执行相同操作时,服务器工作正常,除了启动它之外,我没有在服务器中更改任何内容。如果我将url更改为localhost:8080/index.html,它可以工作,但找不到任何共享文件,即js和localhost:8080/shared/js中不再找到的文件/
"GET /public/index.html" Error (404): "not found"