Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
CSS not linking with CGI script
#2
You should really use python's docstrings, then you dont need to print each line such as

html = """Content-type: text/html

<html>
<head>
<link type="text/css" rel="stylesheet" href="/cgi-bin/styles.css" />
</head>
<body>
<select>
    {OPTIONS}
</select>
<p>
My text
</p>
</body>
</html>
""".format(
        OPTIONS=html_list,
        )
print(html)
It also makes it quicker and easier to plugin a value like OPTIONS here. NOTE: you do need the blank line on line 2.


and you cant link the script as if its in the same directory. You have to make the path to from root. Most likely on a linux server your cgi would be in a cgi-bin directory, so even though the scripts are in the same directory, you still need to link it from the root directory. 

so lets say html is the root
/var/www/html

and your scripts live here
/var/www/html/cgi-bin

even though both CSS and your cgi script are in cgi-bin, you need to use 
<link type="text/css" rel="stylesheet" href="/cgi-bin/styles.css" />
instead
Recommended Tutorials:
Reply


Messages In This Thread
CSS not linking with CGI script - by x64 - Nov-11-2016, 01:17 PM
RE: Can not work css file in python cgi - by metulburr - Nov-11-2016, 02:13 PM
RE: CSS not linking with CGI script - by x64 - Nov-11-2016, 02:41 PM
RE: CSS not linking with CGI script - by snippsat - Nov-11-2016, 03:00 PM
RE: CSS not linking with CGI script - by metulburr - Nov-11-2016, 05:35 PM
RE: CSS not linking with CGI script - by nilamo - Nov-11-2016, 07:25 PM
RE: CSS not linking with CGI script - by x64 - Nov-12-2016, 06:41 AM
RE: CSS not linking with CGI script - by metulburr - Nov-12-2016, 01:51 PM
RE: CSS not linking with CGI script - by wavic - Nov-14-2016, 07:54 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  I need litte help with linking to another website. darktitan 3 2,160 Nov-08-2019, 01:17 PM
Last Post: darktitan

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020