Created
May 16, 2019 18:42
-
-
Save kgriffs/e73540ea9ef8d0eaa6dea84fdde48abd to your computer and use it in GitHub Desktop.
Falcon - Access Query String Params
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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