Skip to content

Commit 12b1a89

Browse files
committed
new Code added ...
1 parent 21d974a commit 12b1a89

File tree

2 files changed

+68
-10
lines changed

2 files changed

+68
-10
lines changed

Get_Request_REST_API.py

+14-10
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ def Get_Embeddings_Sentences_API(textoflink):
44
listofsentences_embeddings = []
55
try:
66
session = requests.Session()
7-
session.headers.update({'Authorization': 'Token ?'})
8-
resultAPi = session.post('http://127.0.0.1:8000/v1/beta/api/embeddings_sentences/',
7+
session.headers.update(
8+
{'Authorization': 'Token ?'})
9+
resultAPi = session.post('http://127.0.0.1:9000/v1/beta/api/embeddings_sentences/',
910
data={'text': textoflink})
11+
print(resultAPi.content)
1012
if resultAPi.status_code == 200:
1113
listofsentences_embeddings = resultAPi.json()
1214
else:
@@ -17,11 +19,13 @@ def Get_Embeddings_Sentences_API(textoflink):
1719

1820
return listofsentences_embeddings
1921

20-
listres=Get_Embeddings_Sentences_API("cat play with ball.\r\n cat is on the table.")
21-
if 'error' not in listres:
22-
for key in listres['Embeddings']:
23-
for i in key.items():
24-
print("sentence :",i[0])
25-
print("embbedding :", i[1])
26-
else:
27-
print(listres)
22+
23+
listres = Get_Embeddings_Sentences_API("amin is good boy.")
24+
print(listres)
25+
# if 'error' not in listres:
26+
# for key in listres['Embeddings']:
27+
# for i in key.items():
28+
# print("sentence :",i[0])
29+
# print("embbedding :", i[1])
30+
# else:
31+
# print(listres)

json-pretty-show.py

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import pprint
2+
3+
json_str = '''{'author': 'The Python Packaging Authority','author_email': '[email protected]',
4+
'bugtrack_url': None,'classifiers': ['Development Status :: 3 - Alpha',
5+
'Intended Audience :: Developers',
6+
'License :: OSI Approved :: MIT License',
7+
'Programming Language :: Python :: 2',
8+
'Programming Language :: Python :: 2.6',
9+
'Programming Language :: Python :: 2.7',
10+
'Programming Language :: Python :: 3',
11+
'Programming Language :: Python :: 3.2',
12+
'Programming Language :: Python :: 3.3',
13+
'Programming Language :: Python :: 3.4',
14+
'Topic :: Software Development :: Build Tools'],'description': 'A sample Python project\n'
15+
'=======================\n'
16+
'\n'
17+
'This is the description file for the project.\n'
18+
'\n'
19+
'The file should use UTF-8 encoding and be written using '
20+
'ReStructured Text. It\n'
21+
'will be used to generate the project webpage on PyPI, and '
22+
'should be written for\n'
23+
'that purpose.\n'
24+
'\n'
25+
'Typical contents for this file would include an overview of '
26+
'the project, basic\n'
27+
'usage examples, etc. Generally, including the project '
28+
'changelog in here is not\n'
29+
'a good idea, although a simple "What\'s New" section for the '
30+
'most recent version\n'
31+
'may be appropriate.',
32+
'description_content_type': None,
33+
'docs_url': None,
34+
'download_url': 'UNKNOWN',
35+
'downloads': {'last_day': -1, 'last_month': -1, 'last_week': -1},
36+
'home_page': 'https://github.com/pypa/sampleproject',
37+
'keywords': 'sample setuptools development',
38+
'license': 'MIT',
39+
'maintainer': None,
40+
'maintainer_email': None,
41+
'name': 'sampleproject',
42+
'package_url': 'https://pypi.org/project/sampleproject/',
43+
'platform': 'UNKNOWN',
44+
'project_url': 'https://pypi.org/project/sampleproject/',
45+
'project_urls': {'Download': 'UNKNOWN',
46+
'Homepage': 'https://github.com/pypa/sampleproject'},
47+
'release_url': 'https://pypi.org/project/sampleproject/1.2.0/',
48+
'requires_dist': None,
49+
'requires_python': None,
50+
'summary': 'A sample Python project',
51+
'version': '1.2.0'}
52+
'''
53+
54+
pprint.pprint(json_str)

0 commit comments

Comments
 (0)