在 python 拥抱中访问 HTTP PUT 数据
Access HTTP PUT data in python hug
import hug
something = {'foo': 'bar'}
@hug.put('/')
def update_something():
something['foo'] = <value_of_bar_from_http_put_request>
import hug
something = {'foo': 'bar'}
@hug.put()
def update_something(bar: hug.types.text):
something['foo'] = bar
return something # may be
然后你可以使用requests来测试
import requests
print(requests.put('http://localhost:8000/update_something',
data={'bar': 'foobar'}).json())
import hug
something = {'foo': 'bar'}
@hug.put('/')
def update_something():
something['foo'] = <value_of_bar_from_http_put_request>
import hug
something = {'foo': 'bar'}
@hug.put()
def update_something(bar: hug.types.text):
something['foo'] = bar
return something # may be
然后你可以使用requests来测试
import requests
print(requests.put('http://localhost:8000/update_something',
data={'bar': 'foobar'}).json())