I want to build a simple http server which receives list of text strings and sends simple dynamic html page which presents them in loop (similar to RSS)
It works fine but now I want to control text properties
How can I change text properties e.g. change background to transparent, text size and font?
The page is built using python HTTPserver module
It is sent single simple html page as a respond to GET request and I am not sure how I can embed css or other tricks in the script
Below python function receives string which contains list of strings (text) separated by commas, embeds it as array inside of html script (replaces TEXT with text) and sends it as part of html body in the respond
def write_response(self, text):
print(content)
self.send_response(200)
self.send_header('Content-type', 'text/html; charset=utf-8')
self.end_headers()
f = open('html.txt', "r")
html = f.read()
body = html.replace('TEXT', text)
print(body)
self.wfile.write(body.encode(encoding='utf-8'))
html.txt file
<script>
var example = [TEXT];
textSequence(0);
function textSequence(i) {
if (example.length > i) {
setTimeout(function() {
document.getElementById("sequence").innerHTML = example[i];
textSequence(++i);
}, 1000); // 1 second (in milliseconds)
} else if (example.length == i) { // Loop
textSequence(0);
}
}
</script>
<div id="sequence"></div>
question from:
https://stackoverflow.com/questions/65643206/changing-text-properties-as-part-of-html-script 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…