当前位置:网站首页>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
边栏推荐
- 国外LEAD美国简称对照表
- ProSci LAG3抗体的化学性质和应用说明
- 中国管理科学研究院凝聚行业专家,傅强荣获智库专家“十佳青年”称号
- 3.3 project evaluation
- PHP反序列化+MD5碰撞
- CVPR 2022 | common 3D damage and data enhancement
- Abnova blood total nucleic acid purification kit pre installed relevant instructions
- 王老吉药业“关爱烈日下最可爱的人”公益活动在南京启动
- Go file path operation
- 《SAS编程和数据挖掘商业案例》学习笔记# 19
猜你喜欢
AI 从代码中自动生成注释文档
Duchefa p1001 plant agar Chinese and English instructions
实现浏览页面时校验用户是否已经完成登录的功能
Duchefa丨P1001植物琼脂中英文说明书
培养机器人教育创造力的前沿科技
leetcode:1139. 最大的以 1 为边界的正方形
2. < tag hash table, string> supplement: Sword finger offer 50 The first character DBC that appears only once
当Steam教育进入个性化信息技术课程
Abbkine BCA法 蛋白质定量试剂盒说明书
ProSci LAG3抗体的化学性质和应用说明
随机推荐
National Eye Care Education Conference, 2022 the Fourth Beijing International Youth eye health industry exhibition
Return to blowing marshland -- travel notes of zhailidong, founder of duanzhitang
How to make ERP inventory accounts of chemical enterprises more accurate
leetcode:1139. 最大的以 1 为边界的正方形
XML建模
Abnova CD81 monoclonal antibody related parameters and Applications
Welcome to the game and win rich bonuses: Code Golf Challenge officially launched
Interpreting the daily application functions of cooperative robots
Abnova丨荧光染料 620-M 链霉亲和素方案
培养机器人教育创造力的前沿科技
基于AVFoundation实现视频录制的两种方式
Popular science | does poor English affect the NPDP exam?
Nprogress plug-in progress bar
Use of form text box (II) input filtering (synthetic event)
2.8、项目管理过程基础知识
CCPC 2021 Weihai - G. shinyruo and KFC (combination number, tips)
ClickHouse 复制粘贴多行sql语句报错
如何让化工企业的ERP库存账目更准确
Abnova total RNA Purification Kit for cultured cells Chinese and English instructions
Maker education infiltrating the transformation of maker spirit and culture