1
import hug

something = {'foo': 'bar'}

@hug.put('/')
def update_something():
    something['foo'] = <value_of_bar_from_http_put_request>

How do I access the put data so that I can update something? I looked up this and this but couldn't find anything.

Shekhar
  • 7,095
  • 4
  • 40
  • 45
Lokesh Meher
  • 437
  • 4
  • 15

1 Answers1

4
import hug

something = {'foo': 'bar'}

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

And then you may use requests to test

import requests

print(requests.put('http://localhost:8000/update_something',
    data={'bar': 'foobar'}).json())
Shekhar
  • 7,095
  • 4
  • 40
  • 45