반응형
from flask import Flask, request, jsonify, make_response
from flask_restful import  Api, Resource
from wsgiref.simple_server import make_server

app = Flask(__name__)
api = Api(app)

class Test1(Resource):
    def get(self):
      # response = make_response("Not Found" , 404)
      response = make_response(
         jsonify({
                "code": 100,
                "success":True,
                "message": "Test1 Succes"
         }),
         200
      )

      return response

class Test2(Resource):
    def get(self , param):
        return jsonify(
            {
                "code": 100,
                "success":True,
                "message": param
            }
        )

api.add_resource(Test1, "/test1")
api.add_resource(Test2, "/test2/<int:param>")

server = make_server("localhost", 7777, app)
server.serve_forever()

 

반응형

+ Recent posts