안녕하세요 저는 웹 프로그램에서 파이썬을 처음 사용하고 CSS 스타일 시트를 사용하는 기본 웹 사이트를 만들려고합니다. app.py, index.html 및 style.css의 세 파일이 있습니다. 그들은 모두 같은 디렉토리에 있습니다. app.py를 실행하고 localhost : 8080으로 이동하면 "Hello World!"가 표시되지만 style.css 파일의 스타일이 아니며 터미널에 "HTTP/1.1 GET /style.css"라고 - 404 찾을 수 없음 . 그러나 app.py 파일을 사용하지 않고 chrome에서 index.html 파일을 열면 스타일 서식이 적용됩니다. 어떤 도움이 필요합니까? 미리 감사드립니다. 다음과 같이 내 코드는 다음과 같습니다Python이 CSS 파일을 찾지 못함
app.py :
import web
urls = (
'/', 'Index'
)
app = web.application(urls, globals())
web.config.debug = True
class Index(object):
def __init__(self):
self.render = web.template.render('.')
def GET(self):
return self.render.index()
if __name__ == '__main__':
app.run()
index.html을 :
<!DOCTYPE html>
<html>
<head>
<link type="text/css" rel="stylesheet" href="style.css" />
<title>Basic Web Project</title>
</head>
<body>
<p>Hello World!</p>
</body>
</html>
있는 style.css :
p {
color: green;
font-size: 22px;
}
이렇게했습니다. 고맙습니다! – jkesh