首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >找不到Javascript文件/ ERR_ABORTED

问找不到Javascript文件/ ERR_ABORTED
EN

Stack Overflow用户
提问于 2017-12-24 05:57:27
回答 1查看 1.7K关注 0票数 0

我正在创建一个与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

代码语言:javascript
复制
<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

代码语言:javascript
复制
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'});
EN

回答 1

Stack Overflow用户

发布于 2017-12-24 07:08:04

在app.yaml中,您需要一个静态url处理程序。尝试:

代码语言:javascript
复制
- url: /static
  static_dir: foldername/static

如果静态目录在文件夹内,则需要foldername,其中文件夹与app.yaml处于同一级别。如果static与app.yaml处于同一级别,则它是

代码语言:javascript
复制
- url: /static
  static_dir: static

然后,将您的/js目录放入静态目录中,并将路径更改为:

代码语言:javascript
复制
<script type="text/javascript" src="static/js/trello.js"></script>

或者,保持路径不变,并在app.yaml中创建一个直接指向该路径的处理程序:

代码语言:javascript
复制
- 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处理程序来处理所有这些问题

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/47956352

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档