From 452764a8eb88117c6c71ed77dca059f25ab67cf4 Mon Sep 17 00:00:00 2001 From: pcdinh Date: Fri, 21 Oct 2016 17:55:30 +0700 Subject: [PATCH] Document `request.body` as a way to get raw POST body --- docs/request_data.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/docs/request_data.md b/docs/request_data.md index bc89bb88..8891d07f 100644 --- a/docs/request_data.md +++ b/docs/request_data.md @@ -8,6 +8,7 @@ The following request variables are accessible as properties: `request.json` (any) - JSON body `request.args` (dict) - Query String variables. Use getlist to get multiple of the same name `request.form` (dict) - Posted form variables. Use getlist to get multiple of the same name +`request.body` (bytes) - Posted raw body. To get the raw data, regardless of content type See request.py for more information @@ -15,7 +16,7 @@ See request.py for more information ```python from sanic import Sanic -from sanic.response import json +from sanic.response import json, text @app.route("/json") def post_json(request): @@ -40,4 +41,9 @@ def post_json(request): @app.route("/query_string") def query_string(request): return json({ "parsed": True, "args": request.args, "url": request.url, "query_string": request.query_string }) + + +@app.route("/users", methods=["POST",]) +def create_user(request): + return text("You are trying to create a user with the following POST: %s" % request.body) ```