flask

 

#!/usr/bin/env python
# -*- coding:utf-8 -*-
from flask_cors import CORS
import configure
from flask import Flask, request, render_template
from wyb_policydata_get.xys_get_policy import xys_get_policy
from wyb_script.wyb_script_redis import Wyb_redis_cz
from wyb_script.wyb_script_huize_policy import policy_diudan
from wyb_script.wyb_script_fxyf_policy import fxyf_diudan
from wyb_script.wyb_script_iyf_policy import iyf_diudan

app = Flask(__name__)
app.config.from_object(configure)
CORS(app, supports_credentials=True)


@app.route('/') # 默认get请求
def index():
context = {
"title": "微云保数据补偿",
"myword": "I Love Flask !"}

return render_template("index.html", # render_template函数会自动在templates文件夹中找到对应的html
**context,
)


# 小雨伞订单补偿接口
@app.route('/xys/getpolicy', endpoint='xysgetpolicy', methods=['GET', 'POST', 'PUT'])
def xys_policy():
if request.method == 'GET':
data = request.args['data']
result = xys_get_policy(data, policydata=[])
return result
elif request.method == 'POST':
data = request.form['data']
result = xys_get_policy(data, policydata=[])
return result
else:
return ''


# 慧择丢单查询
@app.route('/huize/losepolicy', endpoint='huizelosepolicy', methods=['GET', 'POST', 'PUT'])
def huize_diudan_policy():
if request.method == 'GET':
day = request.args['day']
result = policy_diudan(day)
return result
elif request.method == 'POST':
day = request.form['day']
result = policy_diudan(day)
return result
else:
return ''


# 梧桐树丢单查询
@app.route('/fxyf/losepolicy', endpoint='fxyflosepolicy', methods=['GET', 'POST', 'PUT'])
def fxyf_diudan_policy():
if request.method == 'GET':
day = request.args['day']
result = fxyf_diudan(day)
return result
elif request.method == 'POST':
day = request.form['day']
result = fxyf_diudan(day)
return result
else:
return ''


# IYF丢单查询
@app.route('/iyf/losepolicy', endpoint='iyflosepolicy', methods=['GET', 'POST', 'PUT'])
def iyf_diudan_policy():
if request.method == 'GET':
day = request.args['day']
result = iyf_diudan(day)
return result
elif request.method == 'POST':
day = request.form['day']
result = iyf_diudan(day)
return result
else:
return ''


# 输入可以查询redis所有key
@app.route('/queryallRedis', endpoint='queryallRedis', methods=['GET', 'POST', 'PUT'])
def queryallRedis():
if request.method == 'GET':
key = request.args['key']
values = Wyb_redis_cz().queryallredis(key)
return values
elif request.method == 'POST':
key = request.form['key']
values = Wyb_redis_cz().queryallredis(key)
return values
else:
return ''


# 输入key删除redis所有db数据
@app.route('/deleteallredis', endpoint='deleteallredis', methods=['GET', 'POST', 'PUT'])
def deleteallRedis():
if request.method == 'GET':
key = request.args['key']
values = Wyb_redis_cz().deleteallredis(key)
return values
elif request.method == 'POST':
key = request.form['key']
values = Wyb_redis_cz().deleteallredis(key)
return values
else:
return ''


if __name__ == '__main__':
app.run(host='192.168.1.8', port=5000)





<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>{{title}}</title>
<link rel="stylesheet" href="{{ url_for('static', filename='css/index.css') }}">
<script src="{{ url_for('static', filename='js/index.js') }}"></script>
</head>

<body>
<u1>
<h1>微云保</h1>
<li><a href = "http://10.7.1.113:8080/jenkins"> Jenkins<hr /></a></li>
<li><a href = "http://10.7.1.113:5000/xys/getpolicy?data=请输入日期"> 输入日期补偿小雨伞<hr /></a></li>

</u1>
</body>
</html>


index.js
url = 'http://10.7.1.113:5000'
function inputDialog(type) {
    if (type == 1) {
        var inputContent = prompt("请输入日期:")
        if (!inputContent) {
            return;
        }
        location.href = url+'/xys/getpolicy?data=' + inputContent;
    }
 
}

index.css
a{
background:backbord;
}




blog同级 run.py
# ! flask/bin/python
from app.wyb_flask_interface import app
from flask_cors import CORS

app.run(host='0.0.0.0', port=5000)
app.run(debug=False)
CORS(app) # 解决跨域问题



























# -*- coding: utf-8 -*-
import paramiko
import time,os

def put_linux(name):
# 创建 ssh 对象
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy)
# 远程主机的ip地址,端口号,在远程主机已经存在的用户名和密码
ssh.connect("192.168.3.55", 22, "root", "cssd20151231@")
time.sleep(3)
# 创建一个对象,这个对象可以操作文件上传下载
sftp = ssh.open_sftp()
# 把win文件传到Linux
windows_path = os.path.join("C:\\app\\%s.apk" % name)
linux_path = "/home/logic/app/wwwroot/update/%s.apk" % name
sftp.put(windows_path, linux_path)
# sftp.get("/opt/logic.tar.gz", windows_path) # 把Linux文件传到本地
ssh.close()

if __name__ == '__main__':
put_linux(name = 'PDA_1220_3.0.1.822')









import hashlib

data = {
"app_key": "25617551",
"fields": "cid,parent_cid,name,is_parent",
"format": "json",
"method ": "taobao.item.seller.get",
"parent_cid": "0",
"sign_method ": "md5",
"timestamp": "2019-06-21 13:05:00",
"v": "2.0",
"sign": "AFB4A78BCE0FDB5EFE119ADD9A39762A"
}

data1 = {
"appId": "",
"param": "cid,parent_cid,name,is_parent",
"channel": "json",
"deviceNo ": "taobao.item.seller.get",
"sign": "0",
"timestamp": "2019-06-21 13:05:00",
}

class SignatureAndVerification(object):
"""MD5签名和验签"""

@classmethod
def data_processing(cls, data):
"""
:param data: 需要签名的数据,字典类型
:return: 处理后的字符串,格式为:参数名称=参数值,并连接
"""
if "sign" in data:
del data["sign"]
if "sign_type" in data:
del data["sign_type"]
dataList = []
for key in sorted(data):
if data[key]:
dataList.append("%s%s" % (key, data[key]))
return "".join(dataList).strip()

@classmethod
def md5_sign(cls, data, api_key):
"""
MD5签名
:param api_key: MD5签名需要的字符串
:return: 签名后的字符串sign
"""
data = cls.data_processing(data)
screat = api_key + data + api_key
print(screat)
md5 = hashlib.md5()
md5.update(screat.encode(encoding='UTF-8'))
print(md5.hexdigest())
return md5.hexdigest()

@classmethod
def md5_verify(cls, data, signature):
"""
md5验签
:param data: 接收到的数据
:param signature: 接收到的sign
:return: 验签结果,布尔值
"""
if cls.md5_sign(data) == signature:
return True
else:
return False


if __name__ == '__main__':
SignatureAndVerification.data_processing(data1)
# SignatureAndVerification.md5_sign(data, api_key='77cf4effb3b743c9be01062c9fcc6efd')





#coding=utf-8
import requests,urllib3
import json
import datetime,time
date_time = (datetime.datetime.now() + datetime.timedelta(days=0)).strftime('%Y-%m-%d')
date_time_miejunshenhe = (datetime.datetime.now() + datetime.timedelta(days=0)).strftime('%Y-%m-%d %H:%M')
urllib3.disable_warnings()
for i in range(2000):
headers = {
"accept": "application/json",
"department": "6",
"content-type": "application/json-patch+json",
"authorization": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJVc2VySWQiOiIxNSIsIkRlcGFydG1lbnRJZCI6IjAiLCJDb21wYW55SWQiOiIwIiwiTWFuY2hpbmVDb2RlIjoiIiwiVGFnIjoiOWVmYzdiMWQtMmEzYy00MjFlLTk1YTAtNTU3OWE4NDdhNTY0IiwibmJmIjoxNzE0MDM3ODI2LCJleHAiOjE3MTQxMjQyMjYsImlhdCI6MTcxNDAzNzgyNiwiaXNzIjoiaHR0cDovL2tvYWxhLmxvZ2ljaGVhbHRoLmNvbSIsImF1ZCI6Imh0dHA6Ly9rb2FsYS5sb2dpY2hlYWx0aC5jb20ifQ.OEnORpjaP3JIAngUFT9Hdk-Hq8ZSk1Ksi4TiiRGXZT8",
"Cookie": "PHP-SESSION=CfDJ8P853sAlAsdOiF1c%2FKzBgVRLyW1s4n41zCnvSjrNeI%2Bw4qGsGERAP5eA0np5t0YgxmH5fF7OHuf%2BoDcatXohW1N0v3Dc%2Fzc2Qtkg1YgX%2BvomJMEycFWkVPFA7LpMcX80TbHjzTvaWXDdGxSYWDzIT6TrFQpJtgyTlgJpqSX7oig%2B; .AspNetCore.Antiforgery.5c_44TGTr3Y=CfDJ8P853sAlAsdOiF1c_KzBgVQGyJlZ-tPec4bbyACmkjUhbOEKrwEPhPnvlQ2BzgzqnTH1v92AHi7nRvsV78CAPa-8odd8PMRmmf2IeCbBuSeM_Ks0YINRNh7TNaTqNpGZjJS3_WpW2AvmA46xj2d6AKA; LogicTokenClamin=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJVc2VySWQiOiIxNSIsIkRlcGFydG1lbnRJZCI6IjAiLCJDb21wYW55SWQiOiIwIiwiTWFuY2hpbmVDb2RlIjoiIiwiVGFnIjoiOWVmYzdiMWQtMmEzYy00MjFlLTk1YTAtNTU3OWE4NDdhNTY0IiwibmJmIjoxNzE0MDM3ODI2LCJleHAiOjE3MTQxMjQyMjYsImlhdCI6MTcxNDAzNzgyNiwiaXNzIjoiaHR0cDovL2tvYWxhLmxvZ2ljaGVhbHRoLmNvbSIsImF1ZCI6Imh0dHA6Ly9rb2FsYS5sb2dpY2hlYWx0aC5jb20ifQ.OEnORpjaP3JIAngUFT9Hdk-Hq8ZSk1Ksi4TiiRGXZT8; Department=6"}
url = 'http://192.168.4.11/api/Stock/StockApply'
data = {"departmentId":"52","applyUserId":"15","remark":"","details":[{"productId":1,"productCount":2,"remark":""},{"productId":3,"productCount":1,"remark":""},{"productId":4,"productCount":1,"remark":""},{"productId":5,"productCount":1,"remark":""}]}
response_sl = requests.post(url=url, headers=headers, data=json.dumps(data), verify=False)
print(response_sl)

 

posted on 2024-08-10 12:02  WapN  阅读(12)  评论(0编辑  收藏  举报

导航