-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchange_static_paths.py
More file actions
27 lines (20 loc) · 949 Bytes
/
change_static_paths.py
File metadata and controls
27 lines (20 loc) · 949 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# -*- coding: utf-8 -*-
import os
import re
for html in os.listdir('./backend/templates/'):
if html.endswith('.html'):
print(html)
html_file = open('./backend/templates/' + html, 'r', encoding='utf-8')
html_text = html_file.read()
html_file.close()
html_static_links_href = re.findall('href="(/static/(.*?))"', html_text)
html_static_links_src = re.findall('src="(/static/(.*?))"', html_text)
for link in html_static_links_href:
html_text = re.sub(link[0], "{{url_for('static', filename='" + link[1] + "')}}",
html_text)
for link in html_static_links_src:
html_text = re.sub(link[0], "{{url_for('static', filename='" + link[1] + "')}}",
html_text)
html_file = open('./backend/templates/' + html, 'w', encoding='utf-8')
html_file.write(html_text)
html_file.close()