栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

flask前端后端交互学习笔记

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

flask前端后端交互学习笔记

input标签中常用的type属性
	type="text"--->文本框
	type="password"--->密码框
	type="radio"--->单选框
	type="checkbox"--->复选框
	type="file"--->图片上传
	type="hidden"--->隐藏控件
	type="image"--->图片按钮
	type="button"--->普通按钮
	type="submit"--->提交按钮
	type="reset"--->重置按钮
	type="number"--->年龄控件
	type="search"--->搜索框
	type="range"--->滑块
	type="tel"--->电话号码
	type="url"--->网址
	type="color"--->颜色选择
	type="email"--->邮箱
	type="datetime-local"--->日期时间控件   
	type="date"--->日期控件
	 type="time"--->时间控件      
	 type="month"--->月份控件     
	 type="week"--->周控件      

Flask 接收html 表单的数据

index.html




    
    Title


欢迎注册用户

app.py

@app.route('/index', methods=['GET', 'POST'])
def register():
    if request.method == 'POST':
        print(request.form.get('username'))
        print(request.form.get('password'))
        print(request.form.get('repassword'))
 
        return '注册成功'
 
    return render_template('register.html')
flash鼠标事件
stage.addEventListener(MouseEvent.CLICK,MouseEventHandle1);
function  MouseEventHandle1 (e:MouseEvent):void {
trace("这是一个鼠标单击的处理");
}

stage.doubleClickEnabled=true;//MouseEvent.DOUBLECLICK事件生效。
stage.addEventListener(MouseEvent.DOUBLE_CLICK,MouseEventHandle2);
function  MouseEventHandle2 (e:MouseEvent):void {
trace("这是一个双击处理");
}

stage.addEventListener(MouseEvent.MOUSE_DOWN,MouseEventHandle3);
function  MouseEventHandle3 (e:MouseEvent):void {
trace("这是一个鼠标按下处理");
}

stage.addEventListener(MouseEvent.MOUSE_MOVE,MouseEventHandle4);
function  MouseEventHandle4 (e:MouseEvent):void {
trace("这是一个鼠标移到场景上的处理");
}

stage.addEventListener(MouseEvent.MOUSE_OUT,MouseEventHandle5);
function  MouseEventHandle5 (e:MouseEvent):void {
trace("鼠标指针移出显示对象时触发事件");
}

stage.addEventListener(MouseEvent.MOUSE_OVER,MouseEventHandle6);
function  MouseEventHandle6 (e:MouseEvent):void {
trace("这是一个鼠标悬停的处理");
}

stage.addEventListener(MouseEvent.MOUSE_UP,MouseEventHandle7);
function  MouseEventHandle7 (e:MouseEvent):void {
trace("这是一个鼠标按下松开后的处理");
}

stage.addEventListener(MouseEvent.MOUSE_WHEEL,MouseEventHandle8);
function  MouseEventHandle8 (e:MouseEvent):void {
trace("这是一个鼠标滚轮的处理");
}

stage.addEventListener(MouseEvent.ROLL_OUT,MouseEventHandle9);
function  MouseEventHandle9 (e:MouseEvent):void {
trace("这是一个鼠标铺开的处理");
}

stage.addEventListener(MouseEvent.ROLL_OVER,MouseEventHandle10);
function  MouseEventHandle10 (e:MouseEvent):void {
trace("这是一个鼠标翻转的处理");
} 
flask使用页面模版 嵌入式的html模版

例一app.py

 #!/usr/bin/python
from flask import flask
app = flask(__name__)
@app.route("/")
def hello():
  return "hello world!"
if __name__ == "__main__":
  app.debug=true
  app.run()

例二app2.py

 #!/usr/bin/python
from flask import flask
app = flask(__name__)
@app.route("/")
def hello():
  return ' 
 
 
 
hello 
 

hello world!

' if __name__ == "__main__": app.debug=true app.run(host='0.0.0.0',port=7000)
页面模版

将上文中嵌入的html页面独立成index.html,

 


  
  hello template


  

hello world!

在页面上只需要调用render_template即可实现url与对应模版的关联,

render_template(“index.html”)

app.py

 #!/usr/bin/python
from flask import flask
from flask import render_template
app = flask(__name__)
@app.route("/")
def hello():
  return render_template("index.html")
if __name__ == "__main__":
  app.debug=true
  app.run(host='0.0.0.0',port=7000)
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/846289.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号