当前位置:网站首页>Write an interface based on flask
Write an interface based on flask
2022-07-05 20:50:00 【vzhb】
background :
because et Item eating cookie For the crawler , I don't want to update manually cookie, So a cookie Thread pool . A cloud server is specialized in automatic production cookie, Then as an interface server , The other one is on the client get obtain cookie.
perhaps This method also works , Two servers share folders directly ,1 Yes 1 signal communication .
------------------------------- Cutting line ----------------------------------------
matters needing attention :
Set up ip And port number , And the public network of the server ip And port number open . The following intranet test .
Interface server :
from flask import Flask,request
import json
app=Flask(__name__)
# We only accept get Method access
@app.route("/test",methods=["GET"])
def check():
# Default return content
return_dict= {'return_code': '200', 'return_info': ' Handle a successful ', 'result': False}
# Judge whether the input parameter is empty
get_data=request.args.to_dict()
if ('name' not in get_data) or ('num' not in get_data):
return_dict['return_code'] = '5004'
return_dict['return_info'] = ' Request parameter error '
return json.dumps(return_dict, ensure_ascii=False)
# Get incoming params Parameters
name=get_data.get('name')
num=get_data.get('num')
# Operate on parameters
return_dict['result']=tt(name,num)
return json.dumps(return_dict, ensure_ascii=False)
# Function function
def tt(name,num):
result_str="%s apply %s individual cookie" %(name,num)
return result_str
if __name__ == "__main__":
#192.168.1.225
app.run(debug=False,host='0.0.0.0')
client :
Web page direct get Take the return value . Pictured 1 Sum graph 2, They are null parameter and normal parameter respectively
among ip And port number can be set by yourself ,0.0.0.0 It's local ip
边栏推荐
- Prosci LAG-3 recombinant protein specification
- ProSci LAG-3 重组蛋白说明书
- Codeforces Round #804 (Div. 2) - A, B, C
- Duchefa细胞分裂素丨二氢玉米素 (DHZ)说明书
- Duchefa MS medium contains vitamin instructions
- Simple understanding of interpolation search
- Make Jar, Not War
- How to make ERP inventory accounts of chemical enterprises more accurate
- bazel是否有学习的必要
- leetcode:1755. 最接近目标值的子序列和
猜你喜欢
When steam education enters personalized information technology courses
小程序事件绑定
2. < tag hash table, string> supplement: Sword finger offer 50 The first character DBC that appears only once
XML建模
IC popular science article: those things about Eco
Norgen AAV提取剂盒说明书(含特色)
从架构上详解技术(SLB,Redis,Mysql,Kafka,Clickhouse)的各类热点问题
[quick start of Digital IC Verification] 2. Through an example of SOC project, understand the architecture of SOC and explore the design process of digital system
PHP反序列化+MD5碰撞
Graph embedding learning notes
随机推荐
How to make ERP inventory accounts of chemical enterprises more accurate
Research and development efficiency improvement practice of large insurance groups with 10000 + code base and 3000 + R & D personnel
Classic implementation of the basic method of intelligent home of Internet of things
matplotlib绘图润色(如何形成高质量的图,例如设如何置字体等)
Use of form text box (II) input filtering (synthetic event)
Implementation of redis unique ID generator
Hongmeng OS' fourth learning
Applet project structure
Duchefa p1001 plant agar Chinese and English instructions
2.<tag-哈希表, 字符串>补充: 剑指 Offer 50. 第一个只出现一次的字符 dbc
中国的软件公司为什么做不出产品?00后抛弃互联网;B站开源的高性能API网关组件|码农周刊VIP会员专属邮件周报 Vol.097
Abnova CD81 monoclonal antibody related parameters and Applications
Is the securities account given by the school of Finance and business safe? Can I open an account?
研学旅游实践教育的开展助力文旅产业发展
从架构上详解技术(SLB,Redis,Mysql,Kafka,Clickhouse)的各类热点问题
Use of thread pool
【UE4】UnrealInsight获取真机性能测试报告
实现浏览页面时校验用户是否已经完成登录的功能
Abnova DNA marker high quality control test program
教你自己训练的pytorch模型转caffe(三)