2

Jinja2とGAEを使用しており、ヘルパー関数を使用してHTMLファイルをレンダリングしています。サブディレクトリ(ゲーミフィケーション)内にネストされたHTMLファイルをレンダリングしようとすると、JinjaがCSSファイルと画像ファイルを引き出していないようです。誰かが私が何をすべきか知っていますか?

私の現在のYAML構造は次のとおりです

handlers:
- url: /favicon\.ico
  static_files: favicon.ico
  upload: favicon\.ico

- url: .*
  script: main.app

libraries:
- name: webapp2
  version: "2.5.1"
- name: jinja2
  version: latest

私の現在のディレクトリ構造はそのようなものです。

Main directory
|
 -- main.py

|
 ----Templates
     |
      --Gamification
        |
         --index.html
           |
            --CSS
              |
               --1.css
           |
            --img
              |
               --1.jpef

main.py

jinja_environment = jinja2.Environment(loader=jinja2.FileSystemLoader(['Templates', 'Templates\Gamification']));
def import_html(self, address, val = {}):
    template = jinja_environment.get_template(address);
    self.write(template.render(val));

問題のhtmlファイルは次のとおりです。

<!DOCTYPE html>
<html>
  <head>
    <title>Gamification</title>
    <link href="css/bootstrap.css" rel="stylesheet">
  </head>

  <body>

<img src = "img/dan.jpeg" class = "img-rounded" />
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script src="js/bootstrap.js"></script>
</body>
</html>
4

2 に答える 2

2

img と css の静的ディレクトリを宣言していないようです。
何かのようなもの:

- url: /css
  static_dir: css
于 2012-09-15T06:09:24.550 に答える