Добрый день. Пробовал разные варианты, везде результаты разные, но не те, что надо.
Так выглядит python
from flask import Flask
from flask import render_template
app = Flask(__name__)
@app.route('/demo.html')
def demo():
subfolders = ['aaaa', 'bbbb', 'cccc', 'dddd', 'eeee']
files = []
for file in subfolders:
files.append(file)
print(files)
folders = ['1', '2', '3', '4', '5']
files1 = []
for file1 in folders:
files1.append(file1)
print(files1)
return render_template('demo.html', sub=files, main=files1)
if __name__=="__main__":
app.run(debug=True)
HTML v1.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="static/style.css">
<script type="text/javascript" src="static/script.js"></script>
<title>
{% block title %}
{% endblock %}
</title>
</head>
<body>
{% for x in sub %}
<p>{{ x }}</p>
{% for y in main %}
<p>{{ y }}</p>
{% endfor %}
{% endfor %}
</body>
</html>
<!DOCTYPE html>
HTML v2.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="static/style.css">
<script type="text/javascript" src="static/script.js"></script>
<title>
{% block title %}
{% endblock %}
</title>
</head>
<body>
{% for x in sub %}
{% for y in main %}
<p>{{ x }}</p>
<p>{{ y }}</p>
{% endfor %}
{% endfor %}
</body>
</html>
<!DOCTYPE html>
Везде выходят вот такие выводы,
ТЫКaaaa
aaaa
aaaa
aaaa
aaaa
bbbb
bbbb
bbbb
bbbb
bbbb
cccc
cccc
cccc
cccc
cccc
dddd
dddd
dddd
dddd
dddd
eeee
eeee
eeee
eeee
eeee
ТЫКaaaa
1
aaaa
2
aaaa
3
aaaa
4
aaaa
5
bbbb
1
bbbb
2
bbbb
3
bbbb
4
bbbb
5
cccc
1
cccc
2
cccc
3
cccc
4
cccc
5
dddd
1
dddd
2
dddd
3
dddd
4
dddd
5
eeee
1
eeee
2
eeee
3
eeee
4
eeee
5
и т.д.
А надо- аaaa 1, bbbb 2, cccc 3, dddd 4, eeee 5