Access HTTP PUT data in python hug
<pre><code>import hug

something = {'foo': 'bar'}

@hug.put('/')
def update_something():
    something['foo'] = &lt;value_of_bar_from_http_put_request&gt;
</code></pre>

<p>How do I access the put data so that I can update <code>something</code>? I looked up <a href="https://github.com/timothycrosley/hug" rel="nofollow">this</a> and <a href="http://www.hug.rest/website/learn" rel="nofollow">this</a> but couldn't find anything.</p>

<pre><code>import hug

something = {'foo': 'bar'}

@hug.put()
def update_something(bar: hug.types.text):
    something['foo'] = bar
    return something  # may be
</code></pre>

<p>And then you may use requests to test</p>

<pre><code>import requests

print(requests.put('http://localhost:8000/update_something',
    data={'bar': 'foobar'}).json())
</code></pre>

python api python-3.x hug