Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

287
Views
FLASK Unable to change CSS with JS file

Trying to change the background with my URL input using jinja2/flask alongside python/javascript.

The alert works. Background color doesn't however. Works on a file that only has html/js/py.

HTML:

<!DOCTYPE html>
<html lang="en">
<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">
    <link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='style.css') }}">
    <script type="text/javascript" src="{{ url_for('static', filename='script.js') }}"></script>
    <title>♟️Checkerboard</title>
</head>
<body>
    <div class = "container">
        {{output}}
    </div>
</body>
</html>

Python

from flask import Flask, render_template, request, redirect
app = Flask(__name__)

@app.route('/')
def hello(): 
    output = "hello world"
    return render_template('index.html', output = output)

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

JAVASCRIPT

alert("Testing");
document.body.style.backgroundColor = "red";

Basically all file links have proven to work. document.body.style.backgroundColor = "red"; proven to work. document.body.style.backgroundColor = "red"; doesn't work in jinja/flask.

Please help.

about 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!