Django REST + Angular2

时间:2016-11-08 15:51:00

标签: django angular deployment pythonanywhere

我尝试在pythonanywhere上部署我的应用并遇到问题。我有这个错误:

  

资源解释为样式表但使用MIME类型传输   text / html的

我不知道为什么会这样。在localhost一切正常。

完整堆栈跟踪:

  

资源解释为样式表但使用MIME类型传输   为text / html:   " http://rodion.pythonanywhere.com/static/node_modules/bootstrap/dist/css/bootstrap.min.css&#34 ;.   rodion.pythonanywhere.com/:12资源被解释为样式表但是   使用MIME类型text / html传输:   " http://rodion.pythonanywhere.com/static/bower_components/alertify.js/themes/alertify.core.css&#34 ;.   rodion.pythonanywhere.com/:13资源被解释为样式表但是   使用MIME类型text / html传输:   " http://rodion.pythonanywhere.com/static/bower_components/alertify.js/themes/alertify.bootstrap.css&#34 ;.   rodion.pythonanywhere.com/:14资源被解释为样式表但是   使用MIME类型text / html传输:   " http://rodion.pythonanywhere.com/static/styles.css&#34 ;.   rodion.pythonanywhere.com/:24资源被解释为样式表但是   使用MIME类型text / html传输:   " http://rodion.pythonanywhere.com/static/libs/fancybox/source/jquery.fancybox.css&#34 ;.   rodion.pythonanywhere.com/:28资源被解释为样式表但是   使用MIME类型text / html传输:   " http://rodion.pythonanywhere.com/static/libs/fancybox/source/helpers/jquery.fancybox-buttons.css&#34 ;.   rodion.pythonanywhere.com/:32资源被解释为样式表但是   使用MIME类型text / html传输:   " http://rodion.pythonanywhere.com/static/libs/fancybox/source/helpers/jquery.fancybox-thumbs.css&#34 ;.   rodion.pythonanywhere.com/:11资源被解释为样式表但是   使用MIME类型text / html传输:   " http://rodion.pythonanywhere.com/static/bower_components/font-awesome/css/font-awesome.min.css&#34 ;.   jquery.min.js:1未捕获的SyntaxError:意外的令牌<   jquery.mousewheel-3.0.6.pack.js:1未捕获的SyntaxError:意外   令牌< jquery.fancybox.pack.js:1未捕获的SyntaxError:意外   令牌< jquery.fancybox-buttons.js:1 Uncaught SyntaxError:Unexpected   令牌< jquery.fancybox-media.js:1未捕获的SyntaxError:意外   令牌< jquery.fancybox-thumbs.js:1 Uncaught SyntaxError:Unexpected   令牌< bootstrap.min.js:1未捕获的SyntaxError:意外的令牌<   alertify.min.js:1未捕获的SyntaxError:意外的令牌<   shim.min.js:1未捕获的SyntaxError:意外的令牌< zone.js:1   未捕获的SyntaxError:意外的令牌< Reflect.js:1未捕获   SyntaxError:意外的令牌< system.src.js:1未捕获的SyntaxError:   意外的令牌< systemjs.config.js:1未捕获的SyntaxError:   意外的令牌< (索引):51 Uncaught ReferenceError:系统不是   定义(...)(匿名函数)@(索引):51

的index.html:

<html>
  <head>
    <base href="/"/>
    <title>PhotoHub</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    {% load staticfiles %}


    <link rel="stylesheet" href="{% static "node_modules/bootstrap/dist/css/bootstrap.min.css" %}">
    <link rel="stylesheet" href="{% static "bower_components/font-awesome/css/font-awesome.min.css" %}"/>
    <link rel="stylesheet" href="{% static "bower_components/alertify.js/themes/alertify.core.css" %}"/>
    <link rel="stylesheet" href="{% static "bower_components/alertify.js/themes/alertify.bootstrap.css" %}"/>
    <link rel="stylesheet" href="{% static "styles.css" %}">

    <!--Final attempt with fancybox-->
    <!-- Add jQuery library -->
    <!--<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>-->
    <script src="{% static "bower_components/jquery/dist/jquery.min.js" %}"></script>
    <!-- Add mousewheel plugin (this is optional) -->
    <script type="text/javascript" src="{% static "libs/fancybox/lib/jquery.mousewheel-3.0.6.pack.js" %}"></script>

    <!-- Add fancyBox -->
    <link rel="stylesheet" href="{% static "libs/fancybox/source/jquery.fancybox.css" %}" type="text/css" media="screen"/>
    <script type="text/javascript" src="{% static "libs/fancybox/source/jquery.fancybox.pack.js" %}"></script>

    <!-- Optionally add helpers - button, thumbnail and/or media -->
    <link rel="stylesheet" href="{% static "libs/fancybox/source/helpers/jquery.fancybox-buttons.css" %}" type="text/css" media="screen" />
    <script type="text/javascript" src="{% static "libs/fancybox/source/helpers/jquery.fancybox-buttons.js" %}"></script>
    <script type="text/javascript" src="{% static "libs/fancybox/source/helpers/jquery.fancybox-media.js" %}"></script>

    <link rel="stylesheet" href="{% static "libs/fancybox/source/helpers/jquery.fancybox-thumbs.css" %}" type="text/css" media="screen" />
    <script type="text/javascript" src="{% static "libs/fancybox/source/helpers/jquery.fancybox-thumbs.js" %}"></script>
    <!--Final attempt with fancybox-->


    <!--<script src="{% static "bower_components/jquery/dist/jquery.min.js" %}"></script>-->
    <script src="{% static "node_modules/bootstrap/dist/js/bootstrap.min.js" %}"></script>
    <script src="{% static "bower_components/alertify.js/lib/alertify.min.js" %}"></script>


    <!-- 1. Load libraries -->
     <!-- Polyfill(s) for older browsers -->
    <script src="{% static "node_modules/core-js/client/shim.min.js" %}"></script>
    <script src="{% static "node_modules/zone.js/dist/zone.js" %}"></script>
    <script src="{% static "node_modules/reflect-metadata/Reflect.js" %}"></script>
    <script src="{% static "node_modules/systemjs/dist/system.src.js" %}"></script>
    <!-- 2. Configure SystemJS -->
    <script src="{% static "systemjs.config.js" %}"></script>
    <script>
      System.import('app').catch(function(err){ console.error(err); });
    </script>
  </head>
  <!-- 3. Display the application -->
  <body>
    <photohub></photohub>
  </body>
</html>

1 个答案:

答案 0 :(得分:0)

PythonAnywhere dev here:当我转到任何这些URL时,所提供的内容看起来像HTML而不是CSS。查看您的Web应用程序设置,看起来您还没有完全设置静态文件表 - 您已经定义了/static URL,但是没有将目录放在同一行上以说明文件位于何处/static应该来自。