【page.py】添加话题页接口
This commit is contained in:
+62
-32
@@ -1,18 +1,24 @@
|
|||||||
from flask import Flask,session,render_template,redirect,Blueprint,request
|
from flask import Flask, session, render_template, redirect, Blueprint, request
|
||||||
from snownlp import SnowNLP
|
from snownlp import SnowNLP
|
||||||
from utils.getHomePageData import *
|
from utils.getHomePageData import *
|
||||||
from utils.getHotWordPageData import *
|
from utils.getHotWordPageData import *
|
||||||
from utils.getTableData import *
|
from utils.getTableData import *
|
||||||
from utils.getPublicData import getAllHotWords
|
from utils.getPublicData import getAllHotWords, getAllTopics
|
||||||
from utils.getEchartsData import *
|
from utils.getEchartsData import *
|
||||||
pb = Blueprint('page',__name__,url_prefix='/page',template_folder='templates')
|
from utils.getTopicPageData import *
|
||||||
|
|
||||||
|
pb = Blueprint('page',
|
||||||
|
__name__,
|
||||||
|
url_prefix='/page',
|
||||||
|
template_folder='templates')
|
||||||
|
|
||||||
|
|
||||||
@pb.route('/home')
|
@pb.route('/home')
|
||||||
def home():
|
def home():
|
||||||
username = session.get('username')
|
username = session.get('username')
|
||||||
articleLenMax,likeCountMaxAuthorName,cityMax = getHomeTagsData()
|
articleLenMax, likeCountMaxAuthorName, cityMax = getHomeTagsData()
|
||||||
commentsLikeCountTopFore = getHomeCommentsLikeCountTopFore()
|
commentsLikeCountTopFore = getHomeCommentsLikeCountTopFore()
|
||||||
xData,yData = getHomeArticleCreatedAtChart()
|
xData, yData = getHomeArticleCreatedAtChart()
|
||||||
typeChart = getHomeTypeChart()
|
typeChart = getHomeTypeChart()
|
||||||
createAtChart = getHomeCommentCreatedChart()
|
createAtChart = getHomeCommentCreatedChart()
|
||||||
# getUserNameWordCloud()
|
# getUserNameWordCloud()
|
||||||
@@ -25,17 +31,18 @@ def home():
|
|||||||
xData=xData,
|
xData=xData,
|
||||||
yData=yData,
|
yData=yData,
|
||||||
typeChart=typeChart,
|
typeChart=typeChart,
|
||||||
createAtChart=createAtChart
|
createAtChart=createAtChart)
|
||||||
)
|
|
||||||
|
|
||||||
@pb.route('/hotWord')
|
@pb.route('/hotWord')
|
||||||
def hotWord():
|
def hotWord():
|
||||||
username = session.get('username')
|
username = session.get('username')
|
||||||
hotWordList = getAllHotWords()
|
hotWordList = getAllHotWords()
|
||||||
defaultHotWord = hotWordList[0][0]
|
defaultHotWord = hotWordList[0][0]
|
||||||
if request.args.get('hotWord'):defaultHotWord = request.args.get('hotWord')
|
if request.args.get('hotWord'):
|
||||||
|
defaultHotWord = request.args.get('hotWord')
|
||||||
hotWordLen = getHotWordLen(defaultHotWord)
|
hotWordLen = getHotWordLen(defaultHotWord)
|
||||||
xData,yData = getHotWordPageCreatedAtCharData(defaultHotWord)
|
xData, yData = getHotWordPageCreatedAtCharData(defaultHotWord)
|
||||||
sentences = ''
|
sentences = ''
|
||||||
value = SnowNLP(defaultHotWord).sentiments
|
value = SnowNLP(defaultHotWord).sentiments
|
||||||
if value == 0.5:
|
if value == 0.5:
|
||||||
@@ -54,20 +61,45 @@ def hotWord():
|
|||||||
sentences=sentences,
|
sentences=sentences,
|
||||||
xData=xData,
|
xData=xData,
|
||||||
yData=yData,
|
yData=yData,
|
||||||
comments=comments
|
comments=comments)
|
||||||
)
|
|
||||||
|
|
||||||
|
@pb.route('/hotTopic')
|
||||||
|
def hotTopic():
|
||||||
|
username = session.get('username')
|
||||||
|
topicList = getAllTopics()
|
||||||
|
defaultTopic = topicList[0][0]
|
||||||
|
if request.args.get('topic'):
|
||||||
|
defaultTopic = request.args.get('topic')
|
||||||
|
topicLen = getTopicLen(defaultTopic)
|
||||||
|
xData, yData = getTopicPageCreatedAtCharData()
|
||||||
|
sentences = ''
|
||||||
|
|
||||||
|
# ... 这里要嵌入 topic 相关内容(热度?)来填充 sentences
|
||||||
|
|
||||||
|
comments = getCommentFilterDataTopic(defaultTopic)
|
||||||
|
return render_template('hotWord.html',
|
||||||
|
username=username,
|
||||||
|
topicList=topicList,
|
||||||
|
defaultTopic=defaultTopic,
|
||||||
|
topicLen=topicLen,
|
||||||
|
sentences=sentences,
|
||||||
|
xData=xData,
|
||||||
|
yData=yData,
|
||||||
|
comments=comments)
|
||||||
|
|
||||||
|
|
||||||
@pb.route('/tableData')
|
@pb.route('/tableData')
|
||||||
def tableData():
|
def tableData():
|
||||||
username = session.get('username')
|
username = session.get('username')
|
||||||
defaultFlag = False
|
defaultFlag = False
|
||||||
if request.args.get('flag'):defaultFlag = True
|
if request.args.get('flag'): defaultFlag = True
|
||||||
tableData = getTableDataList(defaultFlag)
|
tableData = getTableDataList(defaultFlag)
|
||||||
return render_template('tableData.html',
|
return render_template('tableData.html',
|
||||||
username=username,
|
username=username,
|
||||||
tableData=tableData,
|
tableData=tableData,
|
||||||
defaultFlag=defaultFlag
|
defaultFlag=defaultFlag)
|
||||||
)
|
|
||||||
|
|
||||||
@pb.route('/articleChar')
|
@pb.route('/articleChar')
|
||||||
def articleChar():
|
def articleChar():
|
||||||
@@ -75,9 +107,9 @@ def articleChar():
|
|||||||
typeList = getTypeList()
|
typeList = getTypeList()
|
||||||
defaultType = typeList[0]
|
defaultType = typeList[0]
|
||||||
if request.args.get('type'): defaultType = request.args.get('type')
|
if request.args.get('type'): defaultType = request.args.get('type')
|
||||||
xData,yData = getArticleCharLikeCount(defaultType)
|
xData, yData = getArticleCharLikeCount(defaultType)
|
||||||
x1Data,y1Data = getArticleCharCommentsLen(defaultType)
|
x1Data, y1Data = getArticleCharCommentsLen(defaultType)
|
||||||
x2Data,y2Data = getArticleCharRepotsLen(defaultType)
|
x2Data, y2Data = getArticleCharRepotsLen(defaultType)
|
||||||
return render_template('articleChar.html',
|
return render_template('articleChar.html',
|
||||||
username=username,
|
username=username,
|
||||||
typeList=typeList,
|
typeList=typeList,
|
||||||
@@ -87,8 +119,8 @@ def articleChar():
|
|||||||
x1Data=x1Data,
|
x1Data=x1Data,
|
||||||
y1Data=y1Data,
|
y1Data=y1Data,
|
||||||
x2Data=x2Data,
|
x2Data=x2Data,
|
||||||
y2Data=y2Data
|
y2Data=y2Data)
|
||||||
)
|
|
||||||
|
|
||||||
@pb.route('/ipChar')
|
@pb.route('/ipChar')
|
||||||
def ipChar():
|
def ipChar():
|
||||||
@@ -98,27 +130,27 @@ def ipChar():
|
|||||||
return render_template('ipChar.html',
|
return render_template('ipChar.html',
|
||||||
username=username,
|
username=username,
|
||||||
articleRegionData=articleRegionData,
|
articleRegionData=articleRegionData,
|
||||||
commentRegionData=commentRegionData
|
commentRegionData=commentRegionData)
|
||||||
)
|
|
||||||
|
|
||||||
@pb.route('/commentChar')
|
@pb.route('/commentChar')
|
||||||
def commentChar():
|
def commentChar():
|
||||||
username = session.get('username')
|
username = session.get('username')
|
||||||
xData,yData = getCommentCharDataOne()
|
xData, yData = getCommentCharDataOne()
|
||||||
genderPieData = getCommentCharDataTwo()
|
genderPieData = getCommentCharDataTwo()
|
||||||
return render_template('commentChar.html',
|
return render_template('commentChar.html',
|
||||||
username=username,
|
username=username,
|
||||||
xData=xData,
|
xData=xData,
|
||||||
yData=yData,
|
yData=yData,
|
||||||
genderPieData=genderPieData
|
genderPieData=genderPieData)
|
||||||
)
|
|
||||||
|
|
||||||
@pb.route('/yuqingChar')
|
@pb.route('/yuqingChar')
|
||||||
def yuqingChar():
|
def yuqingChar():
|
||||||
username = session.get('username')
|
username = session.get('username')
|
||||||
xData,yData,bieData = getYuQingCharDataOne()
|
xData, yData, bieData = getYuQingCharDataOne()
|
||||||
bieData1,bieData2 = getYuQingCharDataTwo()
|
bieData1, bieData2 = getYuQingCharDataTwo()
|
||||||
x1Data,y1Data = getYuQingCharDataThree()
|
x1Data, y1Data = getYuQingCharDataThree()
|
||||||
return render_template('yuqingChar.html',
|
return render_template('yuqingChar.html',
|
||||||
username=username,
|
username=username,
|
||||||
xData=xData,
|
xData=xData,
|
||||||
@@ -127,12 +159,10 @@ def yuqingChar():
|
|||||||
bieData1=bieData1,
|
bieData1=bieData1,
|
||||||
bieData2=bieData2,
|
bieData2=bieData2,
|
||||||
x1Data=x1Data,
|
x1Data=x1Data,
|
||||||
y1Data=y1Data
|
y1Data=y1Data)
|
||||||
)
|
|
||||||
|
|
||||||
@pb.route('/articleCloud')
|
@pb.route('/articleCloud')
|
||||||
def articleCloud():
|
def articleCloud():
|
||||||
username = session.get('username')
|
username = session.get('username')
|
||||||
return render_template('articleContentCloud.html',
|
return render_template('articleContentCloud.html', username=username)
|
||||||
username=username
|
|
||||||
)
|
|
||||||
|
|||||||
Reference in New Issue
Block a user