See https://flask.readthedocs.org/en/0.1/quickstart/ for more.
import flask
app = flask.Flask(__name__)
@app.route('/')
def index():
return "hello"
@app.route('/submit', methods=['POST', 'GET'])
def submit():
return flask.request.values['param']
app.run(host='::', port=5000, threaded=True)
Test it with curl
. Note that I use zsh
, the trailing %
means that there was no \n
sent.
The root endpoint.
> curl http://localhost:5000/
Hello%
The /submit
endpoint, using the GET
method and query parameters.
> curl 'http://localhost:5000/submit?param=bar' -X GET
bar%
The /submit
endpoint, using the POST
method and form values.
> curl http://localhost:5000/submit -X POST --form param=bar
bar%