Hello,
I added 4 functions to the Flask class that make routing basic http
request easier. Now you can write:
@app.get('/')
def get_index():
pass
@app.post('/')
def post_index():
pass
@app.put('/')
def put_index():
pass
@app.delete('/')
def delete_index():
pass
instead of having to write methods=['POST'] in route. This makes writing
RESTful api a lot cleaner.
There are also tests for these methods in the HTTPRoutingTestCase class in
testsuite/basic.py.
I like to know what you think.
Grtz
Hi, On 9/10/11 11:14 PM, Werner wrote: > I added 4 functions to the Flask class that make routing basic http > request easier. Now you can write: Since it's so easy to do yourself we don't really would accept a patch for that. The "official" way to do that are method views: from flask.views import MethodView class Index(MethodView): def get(self): ... def post(self): ... app.add_url_rule('/', view_func=Index.as_view('index')) Regards, Armin
Damn, now I can't put "Contributor to The Flask project" on my cv. Bummer On Saturday 10 September 2011 at 23:19, Armin Ronacher wrote: > Hi, > > On 9/10/11 11:14 PM, Werner wrote: > > I added 4 functions to the Flask class that make routing basic http > > request easier. Now you can write: > Since it's so easy to do yourself we don't really would accept a patch > for that. The "official" way to do that are method views: > > > from flask.views import MethodView > > > class Index(MethodView): > def get(self): > ... > def post(self): > ... > > app.add_url_rule('/', view_func=Index.as_view('index')) > > > > Regards, > Armin
It's a good improvement though. Could you share the code? El día 10 de septiembre de 2011 18:52, Werner <el.lauwer@gmail.com> escribió: > Damn, now I can't put "Contributor to The Flask project" on my cv. > Bummer > > On Saturday 10 September 2011 at 23:19, Armin Ronacher wrote: > > Hi, > > On 9/10/11 11:14 PM, Werner wrote: > > I added 4 functions to the Flask class that make routing basic http > request easier. Now you can write: > > Since it's so easy to do yourself we don't really would accept a patch > for that. The "official" way to do that are method views: > > > from flask.views import MethodView > > > class Index(MethodView): > def get(self): > ... > def post(self): > ... > > app.add_url_rule('/', view_func=Index.as_view('index')) > > > > Regards, > Armin > > -- Santiago Basulto.-
Here you are: https://github.com/ab3/flask you find it in flask/app.py:960 On Sunday 11 September 2011 at 00:03, Santiago Basulto wrote: > It's a good improvement though. Could you share the code? > > El día 10 de septiembre de 2011 18:52, Werner <el.lauwer@gmail.com (mailto:el.lauwer@gmail.com)> escribió: > > Damn, now I can't put "Contributor to The Flask project" on my cv. > > Bummer > > > > On Saturday 10 September 2011 at 23:19, Armin Ronacher wrote: > > > > Hi, > > > > On 9/10/11 11:14 PM, Werner wrote: > > > > I added 4 functions to the Flask class that make routing basic http > > request easier. Now you can write: > > > > Since it's so easy to do yourself we don't really would accept a patch > > for that. The "official" way to do that are method views: > > > > > > from flask.views import MethodView > > > > > > class Index(MethodView): > > def get(self): > > ... > > def post(self): > > ... > > > > app.add_url_rule('/', view_func=Index.as_view('index')) > > > > > > > > Regards, > > Armin > > > > -- > Santiago Basulto.-