From fa5eb87d7f2a5d02a63e3b4ccf03cb30461271f3 Mon Sep 17 00:00:00 2001 From: AntonObersteiner Date: Fri, 17 May 2024 20:40:29 +0200 Subject: [PATCH] change main so it writes the .html file --- generate.py | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/generate.py b/generate.py index ec42abb..d581cfa 100755 --- a/generate.py +++ b/generate.py @@ -135,9 +135,28 @@ network = Network( ), ) - -if __name__ == "__main__": - for __ in range(200): +def generate_text(number_of_lines = 100): + result = "" + for i in range(200): emissions, _ = network.choose() line = ''.join(emissions) - print(line) + result += line + "\n" + return result + +def read_template(filename = "./template.html"): + with open(filename, "r") as file: + return file.read() + +def write_index(text, filename = "./deploy/index.html"): + with open(filename, "w") as file: + file.write(text) + +def main(): + template = read_template() + generated = generate_text() + text = template.replace("", generated) + write_index(text) + +if __name__ == "__main__": + main() +