0

I am making a web page with python and flask, but when I want to use css the console sends me this error and the changes in the html are not applied. this is the .py file.

from flask import Flask, render_template

app=Flask(__name__)

@app.route("/")
def home():
   return render_template('home.html')


@app.route("/about")
def about():
   return render_template('about.html')

if __name__ == "__main__":
   app.run(debug=True)

//this is the home.html file //

<!DOCTYPE html>
<html lang="es">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial- 
   scale=1.0">
  <title>Document with python</title>
  <link rel="stylesheet" type="text/css" href="{{ 
     url_for('static',filename='css\main.css') }}">
  </head>
  <body>
     <h1>hola mundo, como esta</h1>
  </body>
  </html>

//this is the main.css file //

body {
background: chartreuse;
font-family: 'Courier New', Courier, monospace;

}

edit: already change css \ main.css to css / main.css

8
  • 2
    Change css\main.css to css/main.css Commented Jun 4, 2021 at 20:55
  • I already changed it, but it still doesn't work :( this appeared "GET /static/css/main.css HTTP/1.1" 404 - Commented Jun 4, 2021 at 21:19
  • and main.css is in static/css/? Commented Jun 4, 2021 at 21:24
  • sure, the main.css is in static / css Commented Jun 4, 2021 at 21:33
  • Can you confirm if main.css has read permission? Commented Jun 4, 2021 at 21:45

1 Answer 1

1
<link rel="stylesheet" type="text/css" href="{{ 
 url_for('static',filename='css/main.css') }}">
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.