Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/329.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python破坏性外观中的Flask服务器_Python_Flask - Fatal编程技术网

Python破坏性外观中的Flask服务器

Python破坏性外观中的Flask服务器,python,flask,Python,Flask,我试图在flask中呈现我的网站,因为我在它里面做了一个后端 我使用了以下两种代码: def TestDir(): return render_template('Index/index.html') 及 但它显示出所有的故障: 但在我的电脑上显示正常:你需要为css和js文件设置一个静态文件夹,除非你在初始化Flask时覆盖它 您的应用程序目录应如下所示: /app - app_runner.py /templates /Index

我试图在flask中呈现我的网站,因为我在它里面做了一个后端

我使用了以下两种代码:

    def TestDir():
        return render_template('Index/index.html')

但它显示出所有的故障:


但在我的电脑上显示正常:

你需要为css和js文件设置一个静态文件夹,除非你在初始化Flask时覆盖它

您的应用程序目录应如下所示:

/app
    - app_runner.py
    /templates
        /Index
        - Index.html
    /static
        /css
            - style.css
要访问html中的css文件,请使用以下内容:

应用程序的文件夹结构是什么?更具体地说,css/js文件我的索引在
Templates/index/index.html
中,css在
Templates/index/style.css
中,js在
Templates/index/app.js
中,等等@stoobisht这个问题可能是由很多因素造成的,包括图像加载缓慢,但这很可能是一个CSS问题,你在本地看不到,因为本地速度太快了。你有几个选择。一种是尝试将其剥离到演示问题的最小可能示例。这一练习往往足以指出问题所在。
/app
    - app_runner.py
    /templates
        /Index
        - Index.html
    /static
        /css
            - style.css