1 html 打開調式效果如下
2 用python后台編寫
# coding:utf-8
# 從同一個位置導入多個工具,
# 這些工具之間可以用逗號隔開,同時導入
# render_template渲染母版
from flask import Flask,render_template
app=Flask(__name__)
# 裝飾器,路由用來封裝鏈接,同時返回數據
@app.route('/index')
def index_xxx():
# 導入html
# 需要在桌面建立一個templates文件夾,
# 將html放到這個文件夾
return render_template('home1.html')
# 在函數中只要導入return,return后面的代碼就不執行了
return 'python!!'
@app.route('/login')
def login():
# 導入html
# return render_template('home.html')
# 在函數中只要導入return,return后面的代碼就不執行了
return 'python!!'
app.debug=True
# 跑服務器
app.run()
# 若果是絕對路徑,建立文件夾templates,
# 因為默認的就是這一個文件夾
3..而且還要利用VS Code編寫前台展現的基本頁面
<body>
<div>歡迎來到Jaoany的博客!</div>
<!--action="/commit"里面是要訪問登陸頁面的鏈接-->
<form action="/commit">
<!--<div>html是前端</div>-->
<input type="text"name="username" placeholder="請輸入用戶名:">
<input type="password" name="psw" placeholder="請輸入密碼:">
<input type="submit" value="登陸">
</form>
</body>
4 編寫后台和前台的環境
Subline Text 2是編寫后台的,VS Code是編寫前台的
