我正在创建一个与Trello API交互的javascript文件,但当我运行该文件时,它在Chrome开发工具中显示:
GET http://localhost:8080/js/trello.js net::ERR_ABORTED
GET http://localhost:8080/js/trello.js 404 (Not Found)
trello.js肯定是在/js中,我只尝试了/trello.js,但似乎什么都不起作用。有谁能帮帮新手吗?我正在使用谷歌应用程序引擎与Python和webapp2。
HTML
<html>
<head>
<title>Admin Page</title>
</head>
<script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
<script src="https://api.trello.com/1/client.js?key={APIKey}"></script>
<script type="text/javascript" src="js/trello.js"></script>
<body>
{% if admin %}
<p>All Work Requests</p>
<a href="{{ logout_url }}">log out</a><br>
<a href="trello.js">Trello test</a>
{% for result in results %}
<table>
<tr>
<th><b>{{ result.email }}</th>
<th><b> {{ result.date }}</th>
<th><b> {{ result.title }}</th>
<th><b> {{ result.key.id() }}</th>
<th><a href="/delete/{{ result.key.id() }}">Delete</a></th>
<th><a href="/assign/{{ result.key.id() }}">Assign</a></th>
</tr>
</table>
{% endfor %}
<p>{{ result }}</p>
{% else %}
<p>Welcome please <a href="{{ login_url }}">login...</a>
<p>Not admin</p>
{% endif %}
</body>
</html>trello.js
var authenticationSuccess = function() {
console.log('Successful authentication');
};
var authenticationFailure = function() {
console.log('Failed authentication');
};
window.Trello.authorize({
type: 'popup',
name: 'Getting Started Application',
scope: {
read: 'true',
write: 'true' },
expiration: 'never',
success: authenticationSuccess,
error: authenticationFailure
});
var myList = 'removed';
var creationSuccess = function (data) {
console.log('Card created successfully.');
console.log(JSON.stringify(data, null, 2));
};
var newCard = {
name: 'New Test Card',
desc: 'This is the description of our new card.',
// Place this card at the top of our list
idList: myList,
pos: 'top'
};
window.Trello.post('/cards/', newCard, creationSuccess);
//window.Trello.put('/cards/[ID]', {name: 'New Test Card'});发布于 2017-12-24 07:08:04
在app.yaml中,您需要一个静态url处理程序。尝试:
- url: /static
static_dir: foldername/static如果静态目录在文件夹内,则需要foldername,其中文件夹与app.yaml处于同一级别。如果static与app.yaml处于同一级别,则它是
- url: /static
static_dir: static然后,将您的/js目录放入静态目录中,并将路径更改为:
<script type="text/javascript" src="static/js/trello.js"></script>或者,保持路径不变,并在app.yaml中创建一个直接指向该路径的处理程序:
- url: /js
static_dir: somefolder/static/js
# or static_dir: static/js if inside static dir which is at same level as app.yaml
# or static_dir: js if js dir at same level as app.yaml我更喜欢将所有静态文件放在一个static目录中。如static/js、static/img、static/fonts等。顶级解决方案使用单个static url处理程序来处理所有这些问题
https://stackoverflow.com/questions/47956352
复制相似问题