You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
790 B
26 lines
790 B
from flask import Blueprint, render_template, request, session
|
|
from module.favorite import Favorite
|
|
|
|
favorite = Blueprint("favorite",__name__)
|
|
|
|
# 添加收藏
|
|
@favorite.route('/favorite',methods = ['post'])
|
|
def add_favorite():
|
|
articleid = request.form.get('articleid') # 通过post从前端页面那边拿取数据
|
|
if session.get('islogin') is None:
|
|
return 'not-login'
|
|
else:
|
|
try:
|
|
Favorite.insert_favorite(articleid = articleid)
|
|
return 'favorite-pass'
|
|
except:
|
|
return 'favorite-fail'
|
|
|
|
# 取消收藏
|
|
@favorite.route('/favorite/<int:articleid>',methods = ['DELETE'])
|
|
def cancle_favorite(articleid):
|
|
try:
|
|
Favorite.cancel_favorite(articleid)
|
|
return 'cancle-pass'
|
|
except:
|
|
return 'cancle-fail' |