Python web development (continuously updated ing...)
The gods are silent - personal CSDN blog post directory
The requirement scenario of this article is: I now have a table in JSON format. The specific format is not important. I believe you can understand how to change tables in other formats. In short, I want to use Python+Flask to extract this form and display it on an HTML page.
The final rendering effect (it is not beautified at all):
Article directory
1. HTML section
conference.html
<!DOCTYPE html>
<html>
<head>
<title>Table</title>
</head>
<body>
<table>
<thead>
<tr>
{% for header in headers %}
<th>{
{ header }}</th>
{% endfor %}
</tr>
</thead>
<tbody>
{% for row in rows %}
<tr>
{% for cell in row %}
<td>{
{ cell }}</td>
{% endfor %}
</tr>
{% endfor %}
</tbody>
</table>
</body>
</html>
2. Python code part
@app.route('/conference',methods={
'GET','POST'})
def conference():
table_json=json.load(open('conference_recommendation/conference_information.json'))
headers=['会议简称','学科','会议级别','会议全称','2023年官网','2023年DDL','DBLP官网']
rows=[]
for k in table_json:
for sample in table_json[k]:
row=[]
row.append(sample['conference_jiancheng'])
row.append(k)
row.append(sample['rate'])
row.append(sample['conference_quancheng'])
row.append(sample['official_site'])
row.append(sample['deadline'])
row.append(sample['dblp_official_site'])
rows.append(row)
return render_template('conference.html', headers=headers, rows=rows)
3. Other network materials referred to in the process of writing this article
In fact, the core reference material is ChatGPT...