Visual Studio Code 에서 python flask app.py 파일 코딩
from flask import Flask
from flask_restful import Api
# resouces > recipe.py 의 class 를 import 해서 경로로 사용
from resources.recipe import RecipeListResource
app = Flask(__name__)
api = Api(app)
# 경로(path)와 리소스(API 코드)를 연결한다.
api.add_resource(RecipeListResource, '/recipes')
if __name__ == '__main__':
app.run()
from flask_restful import Resource
class RecipeListResource(Resource):
def post(self):
return {'data' : 'hello'}
'Restful API' 카테고리의 다른 글
[Restful API] Python MySQL Connector insert (2) | 2024.05.21 |
---|---|
[Restful API] Python Flask로 RESTful API 서버 개발, Resource 클래스 활용 (0) | 2024.05.21 |
[Restful API] API 경로와 Resource 클래스 연결 (0) | 2024.05.20 |
[Restful API] 가상환경 설정 + 프레임워크와 라이브러리 설치 (0) | 2024.05.20 |
[Restful API] Restful API 란? (0) | 2024.05.20 |