Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,7 +1,6 @@
|
|
| 1 |
from fastapi import FastAPI, HTTPException
|
| 2 |
from fastapi.responses import StreamingResponse
|
| 3 |
import qrcode
|
| 4 |
-
from PIL import Image
|
| 5 |
import io
|
| 6 |
|
| 7 |
app = FastAPI()
|
|
@@ -20,10 +19,10 @@ async def generate_qr(text: str):
|
|
| 20 |
qr.add_data(text.strip())
|
| 21 |
qr.make(fit=True)
|
| 22 |
|
| 23 |
-
|
| 24 |
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
|
| 29 |
-
return StreamingResponse(
|
|
|
|
| 1 |
from fastapi import FastAPI, HTTPException
|
| 2 |
from fastapi.responses import StreamingResponse
|
| 3 |
import qrcode
|
|
|
|
| 4 |
import io
|
| 5 |
|
| 6 |
app = FastAPI()
|
|
|
|
| 19 |
qr.add_data(text.strip())
|
| 20 |
qr.make(fit=True)
|
| 21 |
|
| 22 |
+
img = qr.make_image(fill_color="#0057D8", back_color="white").convert("RGB")
|
| 23 |
|
| 24 |
+
buf = io.BytesIO()
|
| 25 |
+
img.save(buf, format="PNG")
|
| 26 |
+
buf.seek(0)
|
| 27 |
|
| 28 |
+
return StreamingResponse(buf, media_type="image/png")
|