Flask
简介
Flask是一个使用 Python 编写的轻量级 web 应用框架 简单易用,上手快
安装使用
一个具体应用
import sys
import time
import datetime
from flask import Flask,render_template,request,Markup
reload(sys)
sys.setdefaultencoding('utf8' )
app=Flask(__name__)
def fun (position) :
f = open(position,"r" )
data = []
for line in f:
line = line.strip()
li = line.split("|" )
if li[0 ]=='part' or li[0 ]=='plan' :
s = li[1 ]+":" +li[2 ]
data.append(s)
f.close()
return data
@app.route("/C/<i>")
def indexC (i) :
dt = str(i)
position = '/home/auto/' +dt+'_c_tag/' +'000000_0'
data_C = fun(position)
return render_template('cloud_C.html' ,data = data_C)
@app.route("/G/<i>")
def indexG (i) :
dt = str(i)
position = '/home/auto/' +dt+'_g_tag/' +'000000_0'
data_G = fun(position)
return render_template('cloud_G.html' ,data = data_G)
if __name__=="__main__" :
app.run(host='0.0.0.0' ,debug=True )
项目 关键词 人数 时间 项目标记 part 鼻翼缩小 1111 20160410 wzx plan V脸 115 20160410 wzx plan botox 265 20160410 wzx plan 下颌角磨削术 196 20160410 wzx plan 中胚层疗法 10 20160410 wzx
{"name ": "微整形数据" , "children ": [{"name ": "C" , "children ": [{"name ": "atte" , "children ": [{"name ": "1:1683" }, {"name ": "2:228" }, {"name ": "3:92" }, {"name ": "4:51" }, {"name ": "5:197" }] }, {"name ": "part" , "children ": [{"name ": "下巴:2552" }, {"name ": "双眼皮:22552" }, {"name ": "嘴部:982" }, {"name ": "开眼角:2989" }, {"name ": "毛发:2224" }, {"name ": "泪沟:181" }....
Echart
一个词云的例子
<!DOCTYPE html>
<head >
<meta http-equiv ="Content-Type" content ="text/html; charset=utf-8" />
<title > 微整形C网关键词热度预览</title >
</head >
<body >
<div id ="main" style ="height:400px" > </div >
<script src ="http://echarts.baidu.com/build/dist/echarts.js" > </script >
<script type ="text/javascript" >
require .config({
paths: {
echarts: 'http://echarts.baidu.com/build/dist'
}
});
require (
[
'echarts' ,
'echarts/chart/wordCloud'
],
function (ec) {
var myChart = ec.init(document.getElementById('main' ));
function createRandomItemStyle () {
return {
normal: {
color: 'rgb(' + [
Math .round(Math .random() * 160 ),
Math .round(Math .random() * 160 ),
Math .round(Math .random() * 160 )
].join(',' ) + ')'
}
};
}
var option = {
title: {
text: '微整形C网关键词热度预览' ,
link: ''
},
tooltip: {
show: true
},
series: [{
name: '详情' ,
type: 'wordCloud' ,
size: ['49%' , '95%' ],
textRotation : [0 , 0 , 0 , 0 ],
textPadding: 0 ,
autoSize: {
enable: true ,
minSize: 18
},
data: [
{% for item in data %}
{
name:"{{item}}" .split(":" )[0 ],
value:"{{item}}" .split(":" )[1 ],
itemStyle: createRandomItemStyle()
},
{% endfor %}
]
}]
};
myChart.setOption(option);
}
);
</script >
</body >
ElasticSearch
简介
Lucene 基于java,是一个库,需要在程序中引用,逻辑复杂 分布式、实时、易扩展的全文搜索引擎,基于 Lucene 简单易用,上手快
安装启动
重要概念
使用
可以直接将语句写进sh文件执行,也可以直接在命令行执行,查询语句是DSL语言,json格式 检查集群健康 curl ‘localhost:9200/_cat/health?v’
epoch timestamp cluster status node.total node.data shards pri relo init unassign 1464822255 07:04:15 zl-es green 2 2 54 27 0 0 0
查看所有节点列表 curl ‘localhost:9200/_cat/nodes?v’ 查看所有索引列表 curl ‘localhost:9200/_cat/indices?v’
health index pri rep docs.count docs.deleted store.size pri.store.size green marvel-2016.06.01 1 1 30227 0 68.4mb 35.1mb green bank1 5 1 1000 0 842.3kb 423.6kb green bank 5 1 1000 0 837.2kb 418.6kb green customer 5 1 3 0 16kb 8kb
创建索引curl -XPOST ‘localhost:9200/bank/account/_bulk?pretty’ –data-binary @/home/accounts.json 更新update,删除delete,聚合操作,过滤查询…… DSL查询特点 curl -<REST Verb>
<Node>
:<Port>
/<Index>
/<Type><ID>
更新一个字段的值
curl -XPUT 'localhost:9200 /customer/external/1 ?pretty' -d '
{
"name ": "Jane Doe"
}'
删除一个文档
curl -XDELETE 'localhost:9200 /customer/external/_query?pretty' -d '
{
"query ": { "match ": { "name ": "John" } }
}'
返回地址中包含“mill”或者包含“lane”的账户
curl -XPOST 'localhost:9200 /bank/_search?pretty' -d '
{
"query ": { "match ": { "address ": "mill lane" } }
}'