mirror of
https://github.com/rzeldent/esp32cam-rtsp.git
synced 2025-11-12 19:26:22 +00:00
- Moved html from SPIFF to code
- Added script to process html - Added WRover and MStack camera's - Automatic detection PSRAM - Added setting for # frame buffers - Feedback of camera initialization value - Added connected feedback
This commit is contained in:
46
html_to_cpp.py
Normal file
46
html_to_cpp.py
Normal file
@@ -0,0 +1,46 @@
|
||||
# pip install Pillow
|
||||
|
||||
import os
|
||||
import sys
|
||||
import htmlmin
|
||||
|
||||
if (len(sys.argv) <= 2):
|
||||
print('Usage: html_to_cpp.py <input_dir> <file.h>')
|
||||
sys.exit(1)
|
||||
|
||||
input_dir = sys.argv[1]
|
||||
file_h = sys.argv[2]
|
||||
|
||||
file_names = os.listdir(input_dir)
|
||||
file_names = filter(lambda x: x[0] != '.' and os.path.isfile(os.path.join(input_dir, x)), file_names)
|
||||
file_names = sorted(file_names)
|
||||
|
||||
output_file = open(file_h, 'w')
|
||||
output_file.write('//*******************************************************************************\n')
|
||||
output_file.write('// HTML import\n')
|
||||
output_file.write('// Machine generated file\n')
|
||||
output_file.write('// ******************************************************************************\n')
|
||||
output_file.write('\n')
|
||||
|
||||
for file_name in file_names:
|
||||
print(f'Processing: {file_name}... ')
|
||||
|
||||
file_path = os.path.join(input_dir, file_name)
|
||||
file_data_name = f'file_data_{file_name}'.replace('.', '_')
|
||||
|
||||
file = open(file_path, 'r')
|
||||
html = file.read()
|
||||
file.close()
|
||||
|
||||
html_mimified = htmlmin.minify(html, remove_empty_space=True)
|
||||
|
||||
output_file.write('\n')
|
||||
output_file.write('constexpr char ' + file_data_name + '[] = "')
|
||||
# escape "
|
||||
html_mimified_escaped = html_mimified.replace('"', '\\"')
|
||||
output_file.write(html_mimified_escaped)
|
||||
output_file.write('";\n')
|
||||
|
||||
output_file.close()
|
||||
|
||||
print('Done.')
|
||||
Reference in New Issue
Block a user