简体   繁体   English

网页未显示我的CSS

[英]webpage not displaying my css

I am hosting a test web page on cherrypy on Raspberry Pi. 我在Raspberry Pi上的Cherrypy上托管了一个测试网页。 Here is my code for python file: 这是我的python文件代码:

#!/usr/bin/python

import cherrypy

class Control:

    @cherrypy.expose
    def index(self):
        return '''<!DOCTYPE html>
        <html>
            <head>
                <title>RaspiCare</title>

                <meta name="viewport" content="width=device-width, initial-scale=1">

                <link rel="stylesheet" href="static/jquery.mobile-1.4.0.min.css">
                <link rel="stylesheet" href="static/style.css">
                <script src="static/jquery-1.10.2.min.js"></script>
                <script src="static/jquery.mobile-1.4.0.min.js"></script>


            </head>
            <body style="overflow: scroll;overflow-x:hidden;">
                            <div data-role="page" data-theme="a" id="page1">

                <div data-role="header">
                    <img src="static/raspicare_logo.png">

                </div><!-- /header -->

                </div>

            </body>
        </html>
                '''
    @cherrypy.expose
    def turnCamera (**data):

            import pigpio
            import time

            # import serial
            # def servo_control(command):
            # serialport= serial.Serial ("/dev/ttyACM0", 9600, timeout=0.5)
            # serialport.write(command)
            # return serialport.readlines(1)

            servos=4
            key = data['direction']
            if key=="left":
                    servostatus = "left"
                    print servostatus
                    m=1500
            else:
                    m=1000

    ##    m=1500
    ##    while (m >= 500 and m <= 2500):
    ##        if (key =="left"):
    ##            print "left"
    ##            m=m+100
    ##        elif (key =="right"):
    ##            m=m-100

            pigpio.start()

            pigpio.set_servo_pulsewidth(servos, m) 
            servostat= "Servo {} {} {} micro pulses".format(servos[0], key, m)
            print servostat
            time.sleep(1)

            pigpio.stop()

            return servostat


    #shutdown server
    @cherrypy.expose
    def shutdown(self):  
        cherrypy.engine.exit()

import os.path
tutconf = os.path.join(os.path.dirname(__file__), 'tutorial.conf')

if __name__ == '__main__':
    # CherryPy always starts with app.root when trying to map request URIs
    # to objects, so we need to mount a request handler root. A request
    # to '/' will be mapped to Comfort().index().
    cherrypy.quickstart(Control(), config=tutconf)
else:
    # This branch is for the test suite; you can ignore it.
    cherrypy.tree.mount(Control(), config=tutconf)

I have removed most of the html content and trying just to display the header logo. 我删除了大多数html内容,并尝试仅显示标题徽标。 I have everything in my static folder and I am very sure those css files work on other page before. 我的所有内容都在我的static文件夹中,并且我非常确定那些CSS文件之前可以在其他页面上运行。 But why the page does not show the logo or any CSS content? 但是,为什么页面不显示徽标或任何CSS内容?

SOLVED 解决了

This has to do with cherrypy's configuration file. 这与cherrypy的配置文件有关。 The tutorial.conf has to be modified as follow: tutorial.conf必须进行如下修改:

[global]
server.socket_host = "0.0.0.0"
server.socket_port = 8080
server.thread_pool = 10
[/]
tools.staticdir.root = "/directory to the static folder"
[/static]
tools.staticdir.on = True
tools.staticdir.dir = "static"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM