1 Star 0 Fork 1

JuneSun/neo4j_search

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
httpClient_gitee.py 2.64 KB
一键复制 编辑 原始数据 按行查看 历史
JuneSun 提交于 2022-05-22 05:25 . 调用服务的代码
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
import sys
import os
path = os.getcwd()
path = os.path.dirname(path)
sys.path.append(path)
import time
import datetime
import requests
import json
#url中的*.*.*.*指的是部署neo4j查询服务的服务器地址(跟neo4j数据库的地址相同)
def mode_get_1():
""" get """
url = "http://*.*.*.*:80/graph_search?subject=张伯苓&search_type=1"
response = requests.request("GET", url)
resp = response.text
print(json.loads(resp))
def mode_post_1():
""" post """
url = "http://*.*.*.*:80/graph_search"
payload = json.dumps({"subject": "张伯苓", "search_type": 1})
headers = {'Content-Type': 'application/json'}
response = requests.request("POST", url, headers=headers, data = payload)
print(response.text)
def mode_get_2():
""" get """
url = "http://*.*.*.*:80/graph_search?subject=张伯苓&relation=民族&search_type=2"
response = requests.request("GET", url)
resp = response.text
print(json.loads(resp))
def mode_post_2():
""" post """
url = "http://*.*.*.*:80/graph_search"
payload = json.dumps({"subject": "张伯苓", "relation":"民族","search_type": 2})
headers = {'Content-Type': 'application/json'}
response = requests.request("POST", url, headers=headers, data = payload)
print(response.text)
def mode_get_3():
""" get """
url = "http://*.*.*.*:80/graph_search?subject=张伯苓&relation=职业&object=教育家&search_type=3"
response = requests.request("GET", url)
resp = response.text
print(json.loads(resp))
def mode_post_3():
""" post """
url = "http://*.*.*.*:80/graph_search"
payload = json.dumps({"subject": "张伯苓", "relation":"职业", "object":"教育家", "search_type": 3})
headers = {'Content-Type': 'application/json'}
response = requests.request("POST", url, headers=headers, data = payload)
print(response.text)
def mode_get_4():
""" get """
url = "http://*.*.*.*:80/graph_search?subject=张伯苓&object=天津&search_type=4"
response = requests.request("GET", url)
resp = response.text
print(json.loads(resp))
def mode_post_4():
""" post """
url = "http://*.*.*.*:80/graph_search"
payload = json.dumps({"subject": "张伯苓", "object":"天津", "search_type": 4})
headers = {'Content-Type': 'application/json'}
response = requests.request("POST", url, headers=headers, data = payload)
print(response.text)
if __name__ == '__main__':
start = time.time()
#mode_get_4()
mode_post_4()
end = time.time()
delta = end - start
print("Finished time is {}".format(datetime.timedelta(seconds=delta)))
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/june-sun/neo4j_search.git
git@gitee.com:june-sun/neo4j_search.git
june-sun
neo4j_search
neo4j_search
master

搜索帮助