flask导入一个模板加CSS js

from flask import Flask, redirect, url_for,render_template
 
app = Flask(__name__)

@app.route('/')
def index():
   
   return render_template('login.html')



if __name__ == '__main__':
   app.run(debug = True)


<!DOCTYPE HTML>
<html>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<link rel="stylesheet" type="text/css" href= "{{ url_for('static', filename = 'ht.css') }}">
<p class='a'>上面这一行就是导入CSS的方式 {{ url_for('static', filename = 'ht.css') }} css 是需要放到static目录下的 </p>

<body>
      
      <form action = "http://localhost:5000/login" method = "post">
         <p class='a'>输入名字 :</p>
         <p><input type = "text" name = "nm" /></p>
         <p><input type = "submit" value = 提交></p>
      </form>
      
</body>
</html>

猜你喜欢

转载自blog.csdn.net/AnYeZhiYin/article/details/105280491
今日推荐