This is the easiest way to create a Flask app.
When you access http: // localhost: 3000 / hello with a web browser, the save dialog of the json file (content is {'result':'hello world!'}
) Is displayed.
installing flask
pip install flask
hello.py
# -*- coding: utf-8 -*-
from flask import Flask, make_response, jsonify
# flask
app = Flask(__name__)
# rest api
@app.route('/hello', methods=['GET'])
def hello_world():
return make_response(jsonify({'result':'hello world!'}))
# main
if __name__ == "__main__":
app.run(host='localhost', port=3000)
Recommended Posts