python编写简单的html登陆页面(1)

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是编写前台的

 

posted @ 2017-06-09 19:05  Jaoany  阅读(14916)  评论(0编辑  收藏  举报