import sys, json, tomllib, zlib
inputs = ["config.toml", "main.css", "main.js", "index.html"]
files = {}
for name in inputs:
with open(name,'r') as f:
files[name] = f.read()
config = tomllib.loads(files["config.toml"])
configjson = json.dumps(config, separators=(',',':'))
with open("config.js","w") as f:
f.write("config="+configjson+";")
index = files["index.html"]
index = index.replace('', f'')
index = index.replace('', '')
index = index.replace('', '')
index = index.replace('', f'')
data = zlib.compress(index.encode('utf-8'))
out = ', '.join(hex(x) for x in data)
print(f"""
#include
#include "webif-fs.h"
static const char index_html[] PROGMEM = {{ {out} }};
PGM_P index_html_data = index_html;
uint16_t index_html_size = {len(data)};
""")