Upload 7 files
Browse files- Dockerfile +0 -1
- app.py +2 -11
- requirements.txt +0 -8
- routes/__init__.py +1 -0
- routes/baogia_router.py +1 -1
- routes/doanhthu_router.py +1 -1
- routes/pyc_router.py +1 -21
Dockerfile
CHANGED
|
@@ -5,7 +5,6 @@ COPY . .
|
|
| 5 |
|
| 6 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 7 |
|
| 8 |
-
# Copy thư mục chứa routers (bắt buộc)
|
| 9 |
COPY routes/ ./routes/
|
| 10 |
|
| 11 |
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|
|
|
|
| 5 |
|
| 6 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 7 |
|
|
|
|
| 8 |
COPY routes/ ./routes/
|
| 9 |
|
| 10 |
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|
app.py
CHANGED
|
@@ -1,16 +1,7 @@
|
|
| 1 |
from fastapi import FastAPI
|
| 2 |
-
from fastapi.middleware.cors import CORSMiddleware
|
| 3 |
from routes import pyc_router, baogia_router, doanhthu_router
|
| 4 |
|
| 5 |
-
app = FastAPI(
|
| 6 |
-
|
| 7 |
-
app.add_middleware(
|
| 8 |
-
CORSMiddleware,
|
| 9 |
-
allow_origins=["https://doluong6--qlht6.hf.space"],
|
| 10 |
-
allow_credentials=True,
|
| 11 |
-
allow_methods=["*"],
|
| 12 |
-
allow_headers=["*"],
|
| 13 |
-
)
|
| 14 |
|
| 15 |
app.include_router(pyc_router.router, prefix="/pyc")
|
| 16 |
app.include_router(baogia_router.router, prefix="/baogia")
|
|
@@ -18,4 +9,4 @@ app.include_router(doanhthu_router.router, prefix="/doanhthu")
|
|
| 18 |
|
| 19 |
@app.get("/")
|
| 20 |
def root():
|
| 21 |
-
return {"message": "✅ Backend
|
|
|
|
| 1 |
from fastapi import FastAPI
|
|
|
|
| 2 |
from routes import pyc_router, baogia_router, doanhthu_router
|
| 3 |
|
| 4 |
+
app = FastAPI()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
app.include_router(pyc_router.router, prefix="/pyc")
|
| 7 |
app.include_router(baogia_router.router, prefix="/baogia")
|
|
|
|
| 9 |
|
| 10 |
@app.get("/")
|
| 11 |
def root():
|
| 12 |
+
return {"message": "✅ Backend FastAPI is running"}
|
requirements.txt
CHANGED
|
@@ -1,12 +1,4 @@
|
|
| 1 |
fastapi
|
| 2 |
uvicorn
|
| 3 |
-
python-multipart
|
| 4 |
openpyxl
|
| 5 |
-
pandas
|
| 6 |
-
num2words==0.5.12
|
| 7 |
-
sendgrid
|
| 8 |
huggingface_hub
|
| 9 |
-
numpy
|
| 10 |
-
pillow
|
| 11 |
-
opencv-python-headless
|
| 12 |
-
matplotlib
|
|
|
|
| 1 |
fastapi
|
| 2 |
uvicorn
|
|
|
|
| 3 |
openpyxl
|
|
|
|
|
|
|
|
|
|
| 4 |
huggingface_hub
|
|
|
|
|
|
|
|
|
|
|
|
routes/__init__.py
CHANGED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
# init
|
routes/baogia_router.py
CHANGED
|
@@ -4,4 +4,4 @@ router = APIRouter()
|
|
| 4 |
|
| 5 |
@router.get("/test")
|
| 6 |
def test_baogia():
|
| 7 |
-
return {"message": "✅
|
|
|
|
| 4 |
|
| 5 |
@router.get("/test")
|
| 6 |
def test_baogia():
|
| 7 |
+
return {"message": "✅ Báo giá OK"}
|
routes/doanhthu_router.py
CHANGED
|
@@ -4,4 +4,4 @@ router = APIRouter()
|
|
| 4 |
|
| 5 |
@router.get("/test")
|
| 6 |
def test_doanhthu():
|
| 7 |
-
return {"message": "✅
|
|
|
|
| 4 |
|
| 5 |
@router.get("/test")
|
| 6 |
def test_doanhthu():
|
| 7 |
+
return {"message": "✅ Doanh thu OK"}
|
routes/pyc_router.py
CHANGED
|
@@ -22,24 +22,4 @@ async def upload_pyc(
|
|
| 22 |
with open(tmp_path, "wb") as f:
|
| 23 |
f.write(await file.read())
|
| 24 |
|
| 25 |
-
|
| 26 |
-
wb = load_workbook(tmp_path, data_only=True)
|
| 27 |
-
ws = wb.active
|
| 28 |
-
ten_khach = str(ws["I8"].value or "Khach_hang_khong_ten").strip()
|
| 29 |
-
ma_phieu = str(ws["D3"].value).strip().replace("/", "-")
|
| 30 |
-
thang = f"{int(ws['BS3'].value):02}"
|
| 31 |
-
nam = str(ws["BX3"].value)
|
| 32 |
-
thu_muc_khach = f"{ten_khach}_{nam}-{thang}_{ma_phieu}"
|
| 33 |
-
path_in_repo = f"Khach_hang/{thu_muc_khach}/Phieu_yeu_cau/{file.filename}"
|
| 34 |
-
|
| 35 |
-
upload_file(
|
| 36 |
-
path_or_fileobj=tmp_path,
|
| 37 |
-
path_in_repo=path_in_repo,
|
| 38 |
-
repo_id=REPO_ID,
|
| 39 |
-
repo_type="space",
|
| 40 |
-
token=HF_TOKEN
|
| 41 |
-
)
|
| 42 |
-
except Exception as e:
|
| 43 |
-
raise HTTPException(status_code=500, detail=f"Lỗi upload: {e}")
|
| 44 |
-
|
| 45 |
-
return {"message": "✅ Đã upload phiếu yêu cầu thành công"}
|
|
|
|
| 22 |
with open(tmp_path, "wb") as f:
|
| 23 |
f.write(await file.read())
|
| 24 |
|
| 25 |
+
return {"message": f"✅ Đã nhận file {file.filename}"}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|