[FastAPI] 그래프 그리기
from fastapi import FastAPI, Response import matplotlib.pyplot as plt import io app = FastAPI() @app.get("/plot/") async def get_plot(): # 데이터 생성 x = [1, 2, 3, 4, 5] y = [10, 5, 7, 3, 8] fig, ax = plt.subplots() ax.plot(x, y) ax.set_xlabel('X-axis') ax.set_ylabel('Y-axis') ax.set_title('Sample Plot') ax.grid(True) # 그래프를 이미지로 저장 buffer = io.BytesIO() fig.savefig(buffer, format="png") buffer.seek..
2023. 7. 21.
[Django] Books 어플리케이션 (2)
URLconf books 앱 폴더에 urls.py 파일을 만들고 각 페이지에 맞는 URL을 매치한다. from django.urls import path from . import views app_name = 'books' urlpatterns = [ path('', views.BooksModelView.as_view(), name='index'), path('book/', views.BookList.as_view(), name='book_list'), path('author/', views.AuthorList.as_view(), name='author_list'), path('publisher/', views.PublisherList.as_view(), name='publisher_list'), ] 클..
2023. 6. 27.