How can I print something like this:
{
username = admin
email = admin@localhost
id=42
}
With only using a method = ['POST']
and without using render_template
?
PS: I already made it run with ['GET']
Here's my code:
from flask import Flask, jsonify, request
app = Flask(__name__)
@app.route('/', methods=['POST'])
def index():
if request.method == 'POST':
return jsonify(username="admin",
email="admin@localhost",
id="42")
else:
if request.method == 'POST':
return jsonify(username="admin",
email="admin@localhost",
id="42")
if __name__ == "__main__":
app.run()
And what I get is a 405 Method error.