#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2004
    Posts
    71
    Rep Power
    11

    Binding external css to a page


    Hello.
    I appreciate your help very much, (the subject might or might not be
    directly replated to python(I realy don't know what's it related to))
    Binding external css (the basic CSS1 standard) file to an html doesn't work.
    [ It does work if the styles definitions are embedded in the page itself ]
    I'm using apache on linux and I tried 2 browsers ( mozilla 1.5-3(debian) and konqueror 3.1.5 )
    I'm using the very simple example which doesn't work

    #!/usr/bin/python
    print 'Content-Type: text/html\n\n'
    print '''<html>
    <head>
    <link href="jazzy.css" rel="stylesheet" type="text/css" />
    </head>
    <body>
    <h1> hello </h1>
    </body>
    </html>
    '''

    and the css file ( jazzy.css) looks like
    h1 {color: yellow;
    background: yellow;
    }
    p {margin-left: 20px}
    body {background: red;
    color:red
    }


    Both files are in the same virtual directory and both have full permissions(rw) for everyone.
    I Idon't have an idea what the problem is.
    Thanks a lot
    Roy
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2004
    Posts
    1
    Rep Power
    0
    Are you running this as a CGI script?
    I once had the same problem with a JPG.
    After tail'ing apache's error_log I noticed it was
    trying to execute the jpg as a script.
    You might have the same problem.
    Try placing the CSS in the root of your webserver and using
    <link href="/jazzy.css" rel="stylesheet" type="text/css" />

    Best of luck!
  4. #3
  5. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    I dont really see why Python/CGI in general could effect wether a style-sheet is linking to the page properly; one handy thing you can do when working like this is to check the pages source code to make sure everything is being outputted correctly.

    Also, i can't help knowtice that your using xhtml but have no DTD at the top?

    You might also want to look at the Python section of this page for handeling Content-Type headers for XHTML:

    http://www.xml.com/pub/a/2003/03/19/dive-into-xml.html

    Mark.
    programming language development: www.netytan.com Hula

  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2004
    Posts
    71
    Rep Power
    11

    Problem solved


    thanks a lot guys.
    The problem is that Apache is trying somehow to execute every file
    that is in it's virtual directory, therefore, files like jpg, css will
    not be showed properly ( and sometimes will write in the apache's error log file, that it's trying to execute....)
    , the solution is to move the files out
    of the apache virtual directory
    Mark, thanks for the remark, I had some trouble finding good documentation about how to use modules that can validate xml with dtd/ schema, but i'll keep on looking.

IMN logo majestic logo threadwatch logo seochat tools logo