description
Project description
:rocket: RestfulApi :facepunch:
模型部署
Usage
import jieba
from restful_api import Api
pred1 = lambda x, y: x + y
pred2 = lambda x, y: x - y
api = Api(['feat1', 'feat2'], '/post1', pred1)
api = Api(['feat1', 'feat2'], '/post2', pred2, app=api.app)
api = Api(['text'], '/post3', jieba.lcut, app=api.app)
api.app.run()
Test
import requests
json = {'feat1': 1, 'feat2': 10}
requests.post('http://127.0.0.1:5000/post1', json=json).json()
requests.post('http://127.0.0.1:5000/post2', json=json).json()
# {'Probability': 11,
# 'Fields': ['feat1', 'feat2'],
# 'Request': {'feat1': 1, 'feat2': 10}}
# {'Probability': -9,
# 'Fields': ['feat1', 'feat2'],
# 'Request': {'feat1': 1, 'feat2': 10}}
json = {'text': '小米家还不错的公司'}
requests.post('http://127.0.0.1:5000/post3', json=json).json()
# {'Probability': ['小米', '家', '还', '不错', '的', '公司'],
# 'Fields': ['text'],
# 'Request': {'text': '小米家还不错的公司'}}
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
restful_api-0.0.1.tar.gz
(4.5 kB
view hashes)
Built Distribution
Close
Hashes for restful_api-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 39f4059b6e35360301ec3584ea5ccaf8cace3662b9b21e7cdf132e8c3fdd0372 |
|
MD5 | a252e4a4fd171926d11376a76421efbd |
|
BLAKE2b-256 | 89a0280d1aa2be2b8c86bfe9d0105f7722edc7586c6a81221b59e87a99317b09 |