Skip to content

Instantly share code, notes, and snippets.

@kgriffs
Created May 16, 2019 18:42
Show Gist options
  • Save kgriffs/e73540ea9ef8d0eaa6dea84fdde48abd to your computer and use it in GitHub Desktop.
Save kgriffs/e73540ea9ef8d0eaa6dea84fdde48abd to your computer and use it in GitHub Desktop.
Falcon - Access Query String Params
import falcon
import falcon.testing
class Resource:
def on_get(self, req, resp):
# See also: https://falcon.readthedocs.io/en/stable/api/request_and_response.html#falcon.Request.get_param
resp.body = req.get_param('a')
resp.content_type = 'text/plain'
app = falcon.API()
app.add_route('/url', Resource())
client = falcon.testing.TestClient(app)
r = client.simulate_get('/url', params=dict(a='somedata'))
print(r.text)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment