Python Flask:搭建云主机详情页
来自CloudWiki
python
from flask import Flask,render_template app = Flask(__name__) @app.route('/detail/<int:id>') def instance_detail(id): #return "主机详情:"+str(id) return render_template('detail.html',myid=id) if __name__ == '__main__': #app.debug = True app.run( host='0.0.0.0',port="5001",debug="true")
html
<head> <meta charset="UTF-8"> <title>Title</title> </head> <body> <h1>主机详情</h1> <hr> <div><img src="../static/云主机.png" alt="通用的占位符缩略图"></div> <h3>该主机的详情为:ID {{ myid }}</h3> </body> </html>