Python 为什么不';使用Google App Engine呈现html文件后,我的css命令是否在html文件中处理?

Python 为什么不';使用Google App Engine呈现html文件后,我的css命令是否在html文件中处理?,python,html,css,google-app-engine,Python,Html,Css,Google App Engine,因此,我在我的应用程序中有一个基本表单,我使用谷歌应用程序引擎托管它。当我输入一个特定的查询时,比如说“CN”,我希望呈现CN.html文件。我已经重定向了路径和内容,并使用if-else允许在查询“CN”时呈现CN.html文件。但是,CN.html中的所有内联CSS命令都不被考虑,当我查询'CN'时,我重定向到的所有命令都是基本的html文档,没有CSS命令。此外,不显示图像 现在,我把CN.html文件放在我的目录中一个名为“templates”的文件夹中,所有的图像都放在一个名为“ima

因此,我在我的应用程序中有一个基本表单,我使用谷歌应用程序引擎托管它。当我输入一个特定的查询时,比如说“CN”,我希望呈现CN.html文件。我已经重定向了路径和内容,并使用if-else允许在查询“CN”时呈现CN.html文件。但是,CN.html中的所有内联CSS命令都不被考虑,当我查询'CN'时,我重定向到的所有命令都是基本的html文档,没有CSS命令。此外,不显示图像

现在,我把CN.html文件放在我的目录中一个名为“templates”的文件夹中,所有的图像都放在一个名为“images”的文件夹中

注意-“模板”和“图像”还分别包含我的首页的html文件和它们的图像。我不认为这应该是个问题,对吗

在这里,请亲自查看我的问题的实例:

访问www.deploymentapp.appspot.com并搜索“计算机网络”

那么问题出在哪里呢


编辑(包括所有源代码文件以便更好地理解)

CN.html

<html>
<head>
    <title>Computer Network</title>
<link rel = "stylesheet" href = "/stylesheets/cn.css" type = "text/css">
</head>
<body>
    <div id='cn'>
        <img src = "/images/CN.jpg" width = '300px' height = '400px'>
    </div>
    <div id = 'cn_heading'>
        <h1>&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbspComputer Networks</h1>
        <p class = 'pname'>by Andrew Tanenbaum</p>
    </div>
    <div id = 'buy'>
        <a href = '#'><img src = '/images/buy-now.jpg' width = '300px'     height = '100px'></a>
    <div id = 'details'>
        <p>Authored by : Andrew S. Tanenbaum, David J. Wetherall</p> 
        <p>Publisher : Pearson </p>
        <p>Price : Rs. 550 (Inclusive of taxes)</p>
    </div>

    <div id = 'description'>
            <p><h3>&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp  COMPUTER NETWORKS 5TH EDITION</h3>
Computer Networks, Fifth Edition, is the ideal introduction to the networking field. This bestseller reflects the latest networking technologies with a special emphasis on wireless networking, including 802.11, 802.16, Bluetooth&trade, and 3G cellular, paired with fixed-network coverage of ADSL, Internet over cable, gigabit Ethernet, MLPS, and peer-to-peer networks. Notably, this latest edition incorporates new coverage on 3G mobile phone networks, Fiber to the Home, RIFD, delay-tolerant networks, and 802.11 security, in addition to expanded material on Internet routing, multicasting, congestion control, quality of service, real-time transport, and content distribution.

Tanenbaum takes a structured approach to explaining how networks work from the inside out. He starts with an explanation of the physical layer of networking, computer hardware and transmission systems then works his way up to network applications.

Salient Features
<ul>
<li>Wireless networks (802.12 and 802.16)</li>
<li>The 3G networks used by smart phones</li>
<li>RFID and sensor networks</li>
<li>Content Distribution using CDNs</li>
<li>Peer-to-peer networks</li>
<li>Real-time media (from stored, streaming, and live sources)</li>
<li>Internet telephony (voice over IP)</li>
<li>Delay-tolerant networks</li>
    </ul>
</p>
       </div>


        </body>
</html> 
.yaml文件

application: deploymentapp
version: 1
runtime: python27
api_version: 1
threadsafe: yes

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

- url: /images
  static_dir: images

- url: /stylesheets/
  static_dir: stylesheets

- url: .*
  script: main.app

libraries:
- name: webapp2
  version: "2.5.2"
- name: jinja2
  version: latest
以下是处理查询“计算机网络”时发生的情况的处理程序:

class CNHandler(webapp2.RequestHandler):
    def write(self, *a, **kw):
        self.response.out.write(*a, **kw)
    def render_str(self, template, **params):
        t = jinja_env.get_template(template)
        return t.render(params)
    def render(self, template, **kw):
        self.write(self.render_str(template, **kw))
    def get(self):
        self.render("CN.html")

您的css文件未部署,或者您的应用程序配置不正确

例如,在搜索“计算机网络”后,相关样式表将生成404。

关于映像问题,您尚未指定映像的正确路径。例如:

<img src = "CN.jpg" width = '300px' height = '400px'>

应该是:

<img src = "/images/CN.jpg" width = '300px' height = '400px'>

您的css文件未部署,或者您的应用程序配置不正确

例如,在搜索“计算机网络”后,相关样式表将生成404。

关于映像问题,您尚未指定映像的正确路径。例如:

<img src = "CN.jpg" width = '300px' height = '400px'>

应该是:

<img src = "/images/CN.jpg" width = '300px' height = '400px'>


我无法搜索计算机网络,也无法搜索CN。事实上,我似乎什么都找不到。没有任何内容是有效的主题名称!确保计算机网络中的“C”和“N”大写。我将在以后处理其他选项。我们只能推测问题是什么,因为您没有向我们展示任何代码。您的问题可能在多个地方,但在不了解应用程序结构(即url结构、HTML如何指定CSS路径)的情况下,您会让人们猜测。我现在已经包含了上面的源代码。问题似乎是,即使在我部署了CN.html文件之后,我的CN.html文件也没有更新。因此图像和样式无法上传。知道为什么吗?我不能搜索计算机网络,也不能搜索CN。事实上,我似乎什么都找不到。没有任何内容是有效的主题名称!确保计算机网络中的“C”和“N”大写。我将在以后处理其他选项。我们只能推测问题是什么,因为您没有向我们展示任何代码。您的问题可能在多个地方,但在不了解应用程序结构(即url结构、HTML如何指定CSS路径)的情况下,您会让人们猜测。我现在已经包含了上面的源代码。问题似乎是,即使在我部署了CN.html文件之后,我的CN.html文件也没有更新。因此图像和样式无法上传。知道为什么吗?这很有趣。我已经改变了我的html文件中的图像路径,正如我在上面编辑的文章中提到的。但是,即使在部署了已编辑的文件之后,我仍然可以看到未编辑的版本被部署,正如页面源代码所示。为什么会发生这种情况?@ManasChaturvedi您在本地devappserver上验证过这种行为吗?您是否已验证部署成功,并且当前版本已设置为默认版本,因为这是一个部署问题,没有其他问题。没有。即使在我的本地服务器上,文件也没有更新。这当然是一个部署问题……但如何解决这个问题呢?现在这很有趣。我已经改变了我的html文件中的图像路径,正如我在上面编辑的文章中提到的。但是,即使在部署了已编辑的文件之后,我仍然可以看到未编辑的版本被部署,正如页面源代码所示。为什么会发生这种情况?@ManasChaturvedi您在本地devappserver上验证过这种行为吗?您是否已验证部署成功,并且当前版本已设置为默认版本,因为这是一个部署问题,没有其他问题。没有。即使在我的本地服务器上,文件也没有更新。这当然是一个部署问题……但如何解决这个问题呢?