반응형 프로그래밍4 Fast API Tutorial(3.5): toy project(calculator) Fast API의 기능을 간단히 익힌 상태에서, API와 python으로 간단히 웹을 만들 수 있는 streamlit을 이용해 간단한 계산기를 만들어 보자api.py: Fast api 모듈 calculator.py: 계산기 모듈 streamlit_app.py: streamlit 모듈 main.py: Fast api와 streamlit을 실행하는 메인 모듈 우리는 streamlit을 통해 웹 화면에서 x, y 두 float 값과 operator(+, -, /, *)를 입력 -> 입력된 값이 api를 통해 결과를 반환 -> 반환된 결과가 다시 streamlit 웹 화면에 게시되도록 할 예정이다. 1. Fast API이 부분에서는 API 통신을 통해 계산기 인자를 받아 결과를 뱉어내도록 만드는 것이 목표다.1.. 2024. 3. 1. Fast API Tutorial(3): query parameters 전체 코드 from fastapi import FastAPI from enum import Enum from typing import Optional app = FastAPI() @app.get("/", description='this is our first roote') async def base_get_roote(): return {"message":"hello world"} @app.post("/") async def post(): return {"message":"hello from the post roote"} @app.put("/") async def put(): return {"message":"hello from the put roote"} @app.get("/users") async de.. 2024. 2. 24. Fast API Tutorial(2): path parameters 전체 코드 from fastapi import FastAPI from enum import Enum app = FastAPI() @app.get("/", description='this is our first roote') async def base_get_roote(): return {"message":"hello world"} @app.post("/") async def post(): return {"message":"hello from the post roote"} @app.put("/") async def put(): return {"message":"hello from the put roote"} @app.get("/users") async def list_users(): return {"mes.. 2024. 2. 23. Fast API Tutorial(1): introduction api 공부 기록 환경 설정 requirements.txt 파일 작성 fastapi uvicorn[standard] 실습 "message":"hellow world" 터미널에서 호출 방법: univocorn main:app from fastapi import FastAPI app = FastAPI() @app.get("/") async def root(): return {"message":"hello world"} main:app의 의미 - main.py에서의 main - app = FatAPI(), @app에서의 app 만약 main.py를 hello.py로 변경 & app명칭을 world로 변경하면? uvicorn hello:world처럼 입력하면 됨 다시 돌아와서, uvicorn main:app을 .. 2024. 2. 23. 이전 1 다음 반응형