Last active
May 28, 2016 02:21
-
-
Save tony19/18711889f7b04857548a3996bf5d0bbb to your computer and use it in GitHub Desktop.
Python Flask app that shows merging URL 'entry' parameters into array
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
from flask import Flask, request, jsonify | |
app = Flask(__name__) | |
@app.route('/api/test') | |
def test(): | |
return jsonify(entries=request.args.getlist('entry')) | |
if __name__ == '__main__': | |
app.run() | |
# http://stackoverflow.com/a/37494577/6277151 | |
# 1. Run `python get_entries.py` | |
# 2. Open browser to http://localhost:5000/api/test?tag=general_message&entry=One%20message&entry=to%20rule&entry=them%20all | |
# 3. Observe that it returns this string: | |
# { | |
# "entries": [ | |
# "One message", | |
# "to rule", | |
# "them all" | |
# ] | |
# } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment