What is the date and time format for a flash soothing parser?

Let's say that I have the following parser inside the get method:

from flask.ext.restful import reqparse

parser = reqparse.RequestParser()
parser.add_argument('when', type=datetime, help='Input wasn\'t valid!')

And then I want to test the specified get method with curl ...

curl --data "when=[WHAT SHOULD I WRITE HERE?]" localhost:5000/myGet

So the question is, what should I call the get method? I tried many different formats, tried to read the rfc228 standard, etc., but I can not understand the correct format.

+7
source share
1 answer

Sincerely, I had the same problem trying to parse the date and time using RequestParser, and unfortunately the docs are not very useful for this scenario, so after looking and testing the RequestParser and Argument code, I think I found the problem :

type=datetime add_argument, datetime arg, : datetime(arg), , , : 2016-07-12T23:13:3, an integer is required.

%Y-%m-%dT%H:%M:%S datetime, - type=datetime.strptime , , , , :

parser.add_argument('date', type=lambda x: datetime.strptime(x,'%Y-%m-%dT%H:%M:%S'))

, , . partial functool lambda, .

.

+10

All Articles