Question:
my theme change using get from flask doesn’t work even though I made the CSS i was using into a variable it seems to not want to work
Repl link:
Here is the flask:
from flask import Flask, redirect, request
app = Flask(__name__, static_url_path="/static")
@app.route("/")
def index():
page = ""
return page
@app.route("/blog/monster")
def mr():
return redirect("/monster")
@app.route("/blog/monster")
def pr():
return redirect("/pluto")
@app.route("/monster", methods=["GET"])
def monster():
data = request.args
theme = "default"
if data != {}:
theme = data["theme"]
image = "static/images/monster.jpeg"
intro = "Work in progress"
date = "2023/12/25"
Anylasis = "Work in progress"
page = ""
f = open("template/monster.html", "r")
page = f.read()
f.close()
page = page.replace("{image}", image)
page = page.replace("{intro}", intro)
page = page.replace("{Anylasis}", Anylasis)
page = page.replace("{date}", date)
page = page.replace("{theme}", theme)
return page()
@app.route("/pluto", methods=["GET"])
def Pluto():
data = request.args
theme = "default"
if data != {}:
theme = data["theme"]
image = "download (3).jpeg"
intro = (
"Pluto is a Japanese manga series written and illustrated by Naoki Urasawa. It"
" was serialized in Shogakukan's seinen manga magazine Big Comic Original from"
" September 2003 to April 2009, with its chapters collected into eight tankōbon"
" volumes. The series is based on Osamu Tezuka's Astro Boy, specifically The"
" Greatest Robot on Earth 地上最大のロボット, Chijō Saidai no Robotto story"
" arc, and"
" named after the arc's chief villain. Urasawa reinterprets the story as a"
" suspenseful murder mystery starring Gesicht, a Europol robot detective trying"
" to solve the case of a string of robot and human deaths. Takashi Nagasaki is"
" credited as the series co-author. Macoto Tezka, Osamu Tezuka's son,"
" supervised the series, and Tezuka Productions is listed as having given"
" cooperation.The series was licensed and released in English in North America"
" by Viz Media under the name Pluto: Urasawa x Tezuka. An original net anime"
" series, produced by Genco with animation production services by Studio M2,"
" premiered on Netflix in October 2023.Pluto was a critical and commercial"
" success, winning several awards, including the ninth Tezuka Osamu Cultural"
" Prize, and selling over 8.5 million copies.Source Wikipedia"
)
date = "2023/12/25"
heading = "My take on Pluto"
Anylasis = (
"pluto is a masterfully written series that captures the complex emotions of"
" human beings in robots. it gives perspective we have never seen before and it"
" opens our minds to a possibilty of a world where human beings and robots"
" could be the same. With robots living normal lives and even adopting"
" human-like attributes like enjoying food, crying, laghing and smiling. An"
" examples of this is when Geischt the main character keeps on drinking coffee"
" throughout the story even though he cant really taste, another examples is"
" atom a child robot who like geischt is one of the most advanced robots in the"
" world of pluto enjoyes meals and smiles like how a child would if they had"
" their favourite meal. All in all I believe pluto is a series that comes once"
" in a lifetime like most of Naoki urasawas works like monster and 20th century"
" boys they cover different aspects of the world and how we as human beings"
" interact with it in a fictional aspect"
)
page = ""
f = open("template/pluto.html", "r")
page = f.read()
f.close()
page = page.replace("{image}", image)
page = page.replace("{intro}", intro)
page = page.replace("{heading}", heading)
page = page.replace("{Anylasis}", Anylasis)
page = page.replace("{date}", date)
page = page.replace("{theme}", theme)
return page
app.run(host="0.0.0.0", port=81)
here is the HTML they are both the same as I havent started working on monster:
<!DOCTYPE html>
<html>
<head>
<title>Pluto</title>
<link rel="stylesheet"href="static/CSS/{theme}.css">
</head>
<body>
<img src="static/images/{image}">
<p>{intro}</p>
<p>{date}</p>
<h1>{heading}</h1>
<p>{Anylasis}</p>
</body>
here is the CSS:
this is the default theme:
*{
margin: 0;
padding: 0;
box-sizing: border-box;
background-color:cyan;
color:white;
}
this is the fancy theme:
*{
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: 'Poppins', sans-serif;
}
body{
background-image:url("https://tenor.com/n7qeQcYY9qn.gif");
}