Python Tornado Angular JS-未找到Html文件(ui路由器)
在我的代码中Python Tornado Angular JS-未找到Html文件(ui路由器),python,html,angularjs,tornado,Python,Html,Angularjs,Tornado,在我的代码中 File Structure: App- |--- static | |--- css | |--- js | |--- app.js | |--- templates | | --- header.html | | --- template.html | | --- footer.html | | --- index.html |--- startup.py star
File Structure:
App-
|--- static
| |--- css
| |--- js
| |--- app.js
|
|--- templates
| | --- header.html
| | --- template.html
| | --- footer.html
| | --- index.html
|--- startup.py
startup.py:
以下是告诉tornado在何处查找文件的设置
settings = dict (
template_path = os.path.join(os.path.dirname(__file__), "templates"),
static_path = os.path.join(os.path.dirname(__file__), "static"),
debug = True
)
app.js:
下面是使用ui路由器配置路由的angular js
var app = angular.module('app', [
'ui.router'
]);
app.config(['$urlRouterProvider', '$stateProvider',
function($urlRouterProvider, $stateProvide) {
$urlRouterProvider.otherwise('/');
$stateProvide
.state('template', {
url:'/',
templateUrl: 'template.html',
controller: 'myController'
})
}])
index.html:
这是模板文件
<!DOCTYPE html>
<html>
<head >
<title>
</title>
<script type="text/javascript" src=" {{ static_url('lib/js/angular.js') }}"></script>
<script type="text/javascript" src=" {{ static_url('lib/js/angular-ui-router.js') }}"></script>
<script type="text/javascript" src=" {{ static_url('lib/js/jquery-3.2.0.js') }}"></script>
<script type="text/javascript" src=" {{ static_url('lib/js/bootstrap.js') }}"></script>
<script type="text/javascript" src=" {{ static_url('js/app.js') }}"></script>
<link rel="stylesheet" type="text/css" href="{{ static_url('lib/css/bootstrap.css') }}">
<link rel="stylesheet" type="text/css" href="{{ static_url('css/app.css') }}">
</head>
<body ng-app='app'>
<header ng-include src="'header.html'"></header>
<div ui-view>
</div>
<footer ng-include src="'footer.html'"></footer>
</body>
现在我的问题是:
找不到我在index.html中使用的header.html和footer.html。在app.js中,templateUrl:'template.html';也没有找到。当我不使用tornado作为服务器时,它是有效的。但是在tornado服务器中,它不再工作了。请帮帮我。感谢tornado中的,
静态
目录中的所有文件都是自动提供的,但模板并非如此。您需要一个或多个RequestHandlers
来为模板文件提供服务(以及执行填充模板变量所需的任何服务器端工作。如果没有任何模板变量,可能这些应该是静态文件)。还请记住,angular将看到这些文件的url,它可能是磁盘上的文件名,也可能不是,这取决于您在tornado应用程序中设置路由的方式