找不到Javascript文件/ ERR_ABORTED

时间:2017-12-23 21:57:27

标签: javascript python google-app-engine

我正在创建一个与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的Google App Engine。

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'});

1 个答案:

答案 0 :(得分:1)

您需要app.yaml中的静态网址处理程序。尝试:

- url: /static
  static_dir: foldername/static
如果静态目录位于文件夹内,则需要

foldername,其中文件夹与app.yaml处于同一级别。如果staticapp.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/jsstatic/imgstatic/fonts等相同。顶级解决方案使用单个static网址处理程序处理所有内容