Flask-request-params provides Rails-like interface to HTTP Request Parameters for Flask.
Project description
Flask-request-params provides Rails-like interface to HTTP Request Parameters for Flask.
Installation
To install Flask-request-params, simply:
pip install flask-request-params
Or alternatively, you can download the repository and install manually by doing:
git clone git@github.com:bluele/flask-request-params.git cd flask-request-params python setup.py install
Examples
Flask code
from flask import Flask, request, render_template, jsonify from flask_request_params import bind_request_params app = Flask(__name__) app.secret_key = 'secret' # bind rails like params to request.params app.before_request(bind_request_params) # just return request.params @app.route('/echo/<path>', methods=['GET', 'POST']) def echo(path): return jsonify(request.params) app.run(debug=True)
Command Line
# support hash type $ curl -X POST http://localhost:5000/echo/user -d 'user[name]=john&user[password]=pass' { "path": "user", "user": { "name": "john", "password": "pass" } } # support array type $ curl -X POST http://localhost:5000/echo/lang -d 'languages[]=python&languages[]=golang' { "path": "lang", "languages": [ "python", "golang" ] }
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Close
Hashes for Flask-request-params-0.2.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 65c7924bb6d885b8459e59e510728ef9813c6cf057a2b14f54624d9130ad1c54 |
|
MD5 | 4f593acda396e31a5aa1a8c868e19d80 |
|
BLAKE2b-256 | 9000707926ecbe571da343532fcbf38151de4b0a90ce72a662324ad2ef17d063 |