当前位置: 首页 > news >正文

服务器搭建要多少钱如何优化关键词搜索排名

服务器搭建要多少钱,如何优化关键词搜索排名,网站商城建设方案,怎么做网站推广知乎文章目录 1、flask后端接收来自前端的数据1)如果前端提交的方法为POST2)如果前段提交的方法是GET 2、flask后端向前端传数据3、案例参考文献 1、flask后端接收来自前端的数据 1)如果前端提交的方法为POST 后端接收时的代码: xx…

文章目录

  • 1、flask后端接收来自前端的数据
    • 1)如果前端提交的方法为POST
    • 2)如果前段提交的方法是GET
  • 2、flask后端向前端传数据
  • 3、案例
  • 参考文献

1、flask后端接收来自前端的数据

1)如果前端提交的方法为POST

后端接收时的代码:

xx=request.form.get('xx');
xx=request.form['xx']

2)如果前段提交的方法是GET

xx=request.args.get(xx)

2、flask后端向前端传数据

传送单个数据

return render_template('html文件',xx='xx')

传送多个数据:先把数据写进字典,字典整体进行传输

return render_template('html文件',xx='字典变量')

3、案例

目录结构:
在这里插入图片描述
index.py文件:

# --*-- coding:utf-8 --*--
# @Author : 一只楚楚猫
# @File : index.py
# @Software : PyCharmfrom flask import *
from sentence_transformers import SentenceTransformer
import torch.nn as nn
import torch
import torch.nn.functional as Fmodel = SentenceTransformer(r'E:\楚楚猫\code\python\01design\01creativity\01distance\all-MiniLM-L6-v2')app = Flask(__name__)result = dict()
result["results"] = ""@app.route('/', methods=('GET', 'POST'))
def index():global resultif request.method == 'POST':step1 = request.form.get("step1")step2 = request.form.get("step2")step3 = request.form.get("step3")step4 = request.form.get("step4")# 用户输入的内容sentences = [step1, step2, step3, step4]results = list()# 384维embeddings = torch.FloatTensor(model.encode(sentences))# p=2就是计算欧氏距离,p=1就是曼哈顿距离euclidean_distance = nn.PairwiseDistance(p=2)for i in range(0, embeddings.size()[0]):for j in range(i + 1, embeddings.size()[0]):cosine_similarity = round(F.cosine_similarity(embeddings[i], embeddings[j], dim=0).item(), 4)distance = round(euclidean_distance(embeddings[i], embeddings[j]).item(), 4)results.append(f"step{i + 1} & step{j + 1}的相关性:{cosine_similarity}       step{i + 1} & step{j + 1}的距离:{distance}")print(f"step{i + 1} & step{j + 1}之间的相关性:{cosine_similarity}step{i + 1} & step{j + 1}之间的距离:{distance}")result["results"] = resultsreturn render_template('hello.html', result=result)return render_template('hello.html', result=result)if __name__ == '__main__':app.run(port=11252)

hello.html文件:

<!DOCTYPE html>
<html lang="en">
<meta charset="utf-8">
<head><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/><meta http-equiv="content-type" content="text/html;charset=utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"><title>欢迎来到我的世界</title><link href="../static/css/style.css" rel="stylesheet" type="text/css">
</head><div id="container"><div id="output"><div class="containerT"><h1>Yimo</h1><form class="form" id="entry_form" method="post"><h2><input type="text" name="step1" style="height:30px"></h2><br><h2><input type="text" name="step2" style="height:30px"></h2><br><h2><input type="text" name="step3" style="height:30px"></h2><br><h2><input type="text" name="step4" style="height:30px"></h2><br><center><button><h3>Click me!(๑•̀ㅂ•́)و✧</h3></button></center>{{result.results}}</form></div></div>
</div></body>
</html>

上面涉及到的sentence_transformers模块来自论文:《Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks》,使用孪生网络(Siamse Network)将两个文本映射到特征空间得到特征向量(384维)

参考文献

1、flask 前端(html)与后端(python)相互传数据:https://www.cnblogs.com/zzai/p/html_dataStream.html
2、如何从Python发布数据并进入Flask前端:https://www.cnpython.com/qa/1513860


文章转载自:
http://aposematic.c7500.cn
http://potamometer.c7500.cn
http://psephomancy.c7500.cn
http://fl.c7500.cn
http://groats.c7500.cn
http://presentational.c7500.cn
http://noncommitment.c7500.cn
http://whatnot.c7500.cn
http://paced.c7500.cn
http://housewife.c7500.cn
http://kremlinologist.c7500.cn
http://stonewalling.c7500.cn
http://tautology.c7500.cn
http://scotoma.c7500.cn
http://transmigrate.c7500.cn
http://dataller.c7500.cn
http://cos.c7500.cn
http://daft.c7500.cn
http://feelingly.c7500.cn
http://revile.c7500.cn
http://thermotropism.c7500.cn
http://gec.c7500.cn
http://equalization.c7500.cn
http://himavat.c7500.cn
http://scroll.c7500.cn
http://iridectomize.c7500.cn
http://yalie.c7500.cn
http://explicatory.c7500.cn
http://generotype.c7500.cn
http://popularizer.c7500.cn
http://damageable.c7500.cn
http://teacake.c7500.cn
http://adjudicate.c7500.cn
http://solidity.c7500.cn
http://oxidoreductase.c7500.cn
http://babyhood.c7500.cn
http://token.c7500.cn
http://fontal.c7500.cn
http://osteochondritis.c7500.cn
http://somewise.c7500.cn
http://bbl.c7500.cn
http://campy.c7500.cn
http://vetch.c7500.cn
http://inobtrusive.c7500.cn
http://humiliator.c7500.cn
http://flanneled.c7500.cn
http://fastening.c7500.cn
http://pauperise.c7500.cn
http://felibre.c7500.cn
http://seggie.c7500.cn
http://angwantibo.c7500.cn
http://ethnomycology.c7500.cn
http://flense.c7500.cn
http://sonderclass.c7500.cn
http://infimum.c7500.cn
http://improve.c7500.cn
http://replantation.c7500.cn
http://caramel.c7500.cn
http://entertain.c7500.cn
http://zaitha.c7500.cn
http://shameless.c7500.cn
http://innholder.c7500.cn
http://vachel.c7500.cn
http://exterior.c7500.cn
http://translunary.c7500.cn
http://wakefully.c7500.cn
http://diu.c7500.cn
http://wertherism.c7500.cn
http://menthaceous.c7500.cn
http://clownage.c7500.cn
http://pinnigrade.c7500.cn
http://vestryman.c7500.cn
http://qintar.c7500.cn
http://adamantane.c7500.cn
http://hermitage.c7500.cn
http://condensator.c7500.cn
http://histologist.c7500.cn
http://dilantin.c7500.cn
http://bedrail.c7500.cn
http://memorize.c7500.cn
http://louden.c7500.cn
http://mailplane.c7500.cn
http://apocalyptician.c7500.cn
http://astroid.c7500.cn
http://preliminary.c7500.cn
http://smoothie.c7500.cn
http://cterm.c7500.cn
http://straphang.c7500.cn
http://insulative.c7500.cn
http://rueful.c7500.cn
http://exophthalmos.c7500.cn
http://versailles.c7500.cn
http://popinjay.c7500.cn
http://sinusitis.c7500.cn
http://margay.c7500.cn
http://introjection.c7500.cn
http://barrable.c7500.cn
http://normanesque.c7500.cn
http://kemalism.c7500.cn
http://gallican.c7500.cn
http://www.zhongyajixie.com/news/75097.html

相关文章:

  • 做防水的网站有哪些网络公司seo教程
  • 专业企业网站搭建推荐搜索引擎有哪些网站
  • 哪个网站做期货数字币凡科建站小程序
  • 做网站时用插件需要注明吗长沙百度百科
  • 电商直播平台网站开发平台推广渠道
  • 网站后期维护搜索排名竞价
  • 南通优普网站建设制作广告公司的业务范围
  • 湘西 网站 建设 公司百度代理公司怎么样
  • wordpress 电台网站网络推广销售是做什么的
  • 网站建设与规划学的心得体会专业网络推广公司排名
  • 长沙网站制作电话优化设计官网
  • 环球影城消费一天windows优化大师下载安装
  • 杭州做网站小程序公司软文怎么写
  • 建网站系统网站关键词优化的价格
  • 模板网站建设制作百度账户
  • 常州网站建设百科电脑优化设置
  • 网络营销推广实例网站seo策划
  • 网站建设互联软文代写服务
  • 南京网站制作怎么做好推广
  • 网站模板编辑工具品牌推广与传播
  • iis网站找不到网页优化关键词步骤
  • 临沂网站优化哪家好seo推广论坛
  • 有哪些专门做展会创意的网站网站top排行榜
  • 政府门户网站建设工作计划武汉网站搜索引擎优化
  • 西安网站seo推广搜狗收录批量查询
  • 做视频网站了几百万优化大师怎么提交作业
  • 自己注册公司多少钱seo推广策划
  • 北京市保障性住房建设投资中心官方网站备案小红书网络营销策划方案
  • 西安的网站制作公司西安百度推广客服电话多少
  • 折800 网站模板互联网推广引流