python学习
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from flask import Blueprint,render_template
|
||||
|
||||
route_account = Blueprint( 'account_page',__name__ )
|
||||
|
||||
@route_account.route( "/index" )
|
||||
def index():
|
||||
return render_template( "account/index.html" )
|
||||
|
||||
@route_account.route( "/info" )
|
||||
def info():
|
||||
return render_template( "account/info.html" )
|
||||
|
||||
@route_account.route( "/set" )
|
||||
def set():
|
||||
return render_template( "account/set.html" )
|
||||
|
||||
1
web/controllers/account/__init__.py
Normal file
1
web/controllers/account/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
16
web/controllers/finance/Finance.py
Normal file
16
web/controllers/finance/Finance.py
Normal file
@@ -0,0 +1,16 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from flask import Blueprint,render_template
|
||||
|
||||
route_finance = Blueprint( 'finance_page',__name__ )
|
||||
|
||||
@route_finance.route( "/index" )
|
||||
def index():
|
||||
return render_template( "finance/index.html" )
|
||||
|
||||
@route_finance.route( "/pay-info" )
|
||||
def payInfo():
|
||||
return render_template( "finance/pay_info.html" )
|
||||
|
||||
@route_finance.route( "/account" )
|
||||
def account():
|
||||
return render_template( "finance/account.html" )
|
||||
1
web/controllers/finance/__init__.py
Normal file
1
web/controllers/finance/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
26
web/controllers/food/Food.py
Normal file
26
web/controllers/food/Food.py
Normal file
@@ -0,0 +1,26 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from flask import Blueprint,render_template
|
||||
|
||||
route_food = Blueprint( 'food_page',__name__ )
|
||||
|
||||
@route_food.route( "/index" )
|
||||
def index():
|
||||
return render_template( "food/index.html" )
|
||||
|
||||
@route_food.route( "/info" )
|
||||
def info():
|
||||
return render_template( "food/info.html" )
|
||||
|
||||
|
||||
@route_food.route( "/set" )
|
||||
def set():
|
||||
return render_template( "food/set.html" )
|
||||
|
||||
|
||||
@route_food.route( "/cat" )
|
||||
def cat():
|
||||
return render_template( "food/cat.html" )
|
||||
|
||||
@route_food.route( "/cat-set" )
|
||||
def catSet():
|
||||
return render_template( "food/cat_set.html" )
|
||||
1
web/controllers/food/__init__.py
Normal file
1
web/controllers/food/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
@@ -5,4 +5,4 @@ route_index = Blueprint( 'index_page',__name__ )
|
||||
|
||||
@route_index.route("/")
|
||||
def index():
|
||||
return render_template("index/index.html")
|
||||
return render_template( "index/index.html" )
|
||||
21
web/controllers/member/Member.py
Normal file
21
web/controllers/member/Member.py
Normal file
@@ -0,0 +1,21 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from flask import Blueprint,render_template
|
||||
|
||||
route_member = Blueprint( 'member_page',__name__ )
|
||||
|
||||
@route_member.route( "/index" )
|
||||
def index():
|
||||
return render_template( "member/index.html" )
|
||||
|
||||
@route_member.route( "/info" )
|
||||
def info():
|
||||
return render_template( "member/info.html" )
|
||||
|
||||
@route_member.route( "/set" )
|
||||
def set():
|
||||
return render_template( "member/set.html" )
|
||||
|
||||
|
||||
@route_member.route( "/comment" )
|
||||
def comment():
|
||||
return render_template( "member/comment.html" )
|
||||
1
web/controllers/member/__init__.py
Normal file
1
web/controllers/member/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
20
web/controllers/stat/Stat.py
Normal file
20
web/controllers/stat/Stat.py
Normal file
@@ -0,0 +1,20 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from flask import Blueprint,render_template
|
||||
|
||||
route_stat = Blueprint( 'stat_page',__name__ )
|
||||
|
||||
@route_stat.route( "/index" )
|
||||
def index():
|
||||
return render_template( "stat/index.html" )
|
||||
|
||||
@route_stat.route( "/food" )
|
||||
def food():
|
||||
return render_template( "stat/food.html" )
|
||||
|
||||
@route_stat.route( "/member" )
|
||||
def memebr():
|
||||
return render_template( "stat/member.html" )
|
||||
|
||||
@route_stat.route( "/share" )
|
||||
def share():
|
||||
return render_template( "stat/share.html" )
|
||||
1
web/controllers/stat/__init__.py
Normal file
1
web/controllers/stat/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
@@ -1,13 +1,61 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from flask import Blueprint,render_template
|
||||
from flask import Blueprint, render_template, request,jsonify,make_response,redirect
|
||||
from common.models.User import User
|
||||
from common.libs.user.UserService import UserService
|
||||
from application import app,db
|
||||
import json
|
||||
from common.libs.UrlManager import UrlManager
|
||||
|
||||
route_user = Blueprint( 'user_page',__name__ )
|
||||
route_user = Blueprint('user_page', __name__)
|
||||
|
||||
|
||||
@route_user.route("/login", methods=["GET", "POST"])
|
||||
@route_user.route("/login")
|
||||
def login():
|
||||
return render_template("user/login.html")
|
||||
if request.method == "GET":
|
||||
return render_template("user/login.html")
|
||||
resp = {'code': 200, 'msg': '登录成功', 'data': {}}
|
||||
req = request.values
|
||||
login_name = req['login_name'] if 'login_name' in req else ''
|
||||
login_pwd = req['login_pwd'] if 'login_pwd' in req else ''
|
||||
|
||||
if login_name is None or len(login_name)<1:
|
||||
resp['code']=-1
|
||||
resp['msg']="请输入正确的登录用户名"
|
||||
return jsonify(resp)
|
||||
if login_pwd is None or len(login_pwd) < 1:
|
||||
resp['code'] = -1
|
||||
resp['msg'] = "请输入正确的登录密码"
|
||||
return jsonify(resp)
|
||||
|
||||
user_info = User.query.filter_by(login_name=login_name).first()
|
||||
if not user_info:
|
||||
resp['code'] = -1
|
||||
resp['msg'] = "请输入正确的用户名和密码_1"
|
||||
return jsonify(resp)
|
||||
|
||||
if user_info.login_pwd != UserService.genePwd(login_pwd, user_info.login_salt):
|
||||
resp['code'] = -1
|
||||
resp['msg'] = "请输入正确的登录用户名和密码-2~~"
|
||||
return jsonify(resp)
|
||||
|
||||
response = make_response(json.dumps(resp))
|
||||
response.set_cookie(app.config['AUTH_COOKIE_NAME'], '%s#%s' % (
|
||||
UserService.geneAuthCode(user_info), user_info.uid)) # 保存120天
|
||||
return response
|
||||
|
||||
|
||||
@route_user.route("/edit")
|
||||
def edit():
|
||||
return render_template("user/edit.html")
|
||||
@route_user.route("/reset_pwd")
|
||||
|
||||
|
||||
@route_user.route("/reset-pwd")
|
||||
def resetPwd():
|
||||
return render_template("user/reset_pwd.html")
|
||||
return render_template("user/reset_pwd.html")
|
||||
|
||||
@route_user.route("/logout")
|
||||
def logout():
|
||||
response = make_response(redirect(UrlManager.buildUrl("/user/login")))
|
||||
response.delete_cookie(app.config['AUTH_COOKIE_NAME'])
|
||||
return response
|
||||
Reference in New Issue
Block a user