1. 程式人生 > >python flask編寫api介面

python flask編寫api介面

  • hello.py
from flask import Flask  
from flask import request
from flask import redirect
from flask import jsonify
import json

app = Flask(__name__)
@app.route('/api/hello', methods=['GET'])

def start():
  return json.dumps({
    'code': '0'
  })

if __name__ == '__main__':
  app.run()
  • 訪問
http://127.0.0.1:5000/api/hello
{
code: "0"
}