Skip to main content

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)

Uploaded Source

Built Distribution

restful_api-0.0.1-py3-none-any.whl (4.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page