前端知识
参考资料:https://www.imooc.com/learn/864
1 2 3 4 5 6 7 8 9 10 11 12 13 | flask大型教程项目:http: //www.pythondoc.com/flask-mega-tutorial http: //www.imooc.com/learn/40 前端知识学习网站: http: //w3school.com.cn/html/index.asp 淘宝前后端分离:http: //2014.jsconf.cn/slides/herman-taobaoweb/#/ 博文:前后端分离的思考与实践 书:SOA与REST:用REST构建企业级SOA解决方案 书:企业应用架构模式 课程完整开源项目:https: //github.com/litaotao/IPython-Dashboard |
======================
===========================
<head> <!--头 --> <title>Calculator</title> <script src="add.js" type="text/javascript"></script> <!--指定js脚本 --> </head> <body> <div align="center" style="margin-top:40px;"> <!--层,整体改变格式 --> <img src="add.png"> <!--图片 --> </div> <div align="center" style="margin-top:60px;"> <!--层,整体改变格式 --> <form name="form1"> <!--表单 --> <input type="text" placeholder="adder" name="adder1">+ <!--文本框 --> <input type="text" placeholder="adder-2" name="adder2">= <input type="text" readonly="readonly" placeholder="result" name="result"> <input type="button" value="计算" onclick="add()"> <!--按钮 --> </form> </div> </body> <footer> <!--尾 --> </footer>
===========
============wtforms
from flask import Flask from flask import request from flask import render_template from flask import redirect app=Flask(__name__) from wtforms import Form,TextField,PasswordField,validators class LoginForm(Form): username = TextField("username",[validators.Required()]) password = PasswordField("password",[validators.Required()]) @app.route("/user",methods=['GET','POST']) def login(): myForm = LoginForm(request.form) if request.method=='POST': if myForm.username.data=="jikexueyuan" and myForm.password.data=="123456" and myForm.validate(): return redirect("http://www.jikexueyuan.com") else: message="Login Failed" return render_template('index.html',message=message,form=myForm) return render_template('index.html',form=myForm) if __name__=="__main__": app.run(port=8080)
======================
import MySQLdb conn = MySQLdb.connect("localhost","root","","test") cur = conn.cursor() def insert(username,password): sql = "insert into user (username,password) values ('%s','%s')" %(username,password) cur.execute(sql) conn.commit() conn.close() def isExisted(username,password): sql="select * from user where username ='%s' and password ='%s'" %(username,password) cur.execute(sql) result = cur.fetchall() if (len(result) == 0): return False else: return True
SQL注入:select * from users where name=1 and pwd=1 or 1=1
SQLAlchemy 是flask中常用的ORM
===========指定版本的安装
pip install pymongo==2.8
============