-
Notifications
You must be signed in to change notification settings - Fork 0
/
sub.py
43 lines (38 loc) · 895 Bytes
/
sub.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# REST API 호출, 이미지 파일 처리에 필요한 라이브러리
import requests
from io import StringIO
import json
import urllib
from typing import Annotated
from PIL import Image
from fastapi.middleware.cors import CORSMiddleware
import pyqrcode
import base64
from PIL import Image
import PIL.Image
import io
from pydantic import BaseModel
import cv2
import numpy as np
from fastapi.staticfiles import StaticFiles
from fastapi.responses import FileResponse
import os
from io import BytesIO
# fastapi 설정
from fastapi import FastAPI, Form
app = FastAPI()
origins = [
"*"
]
IMAGES_DIR = "./static"
app.mount("/static", StaticFiles(directory=IMAGES_DIR), name="static")
app.add_middleware(
CORSMiddleware,
allow_origins=origins,
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
@app.get("/")
def upload(string: str = ""):
return string