From 715162b0eaef574cd59c4dee9980221681c57b20 Mon Sep 17 00:00:00 2001 From: Nucha Date: Thu, 12 Jun 2025 09:28:47 +0700 Subject: [PATCH] fet:---> --- __pycache__/main.cpython-312.pyc | Bin 0 -> 698 bytes main.py | 8 ++++++ requirements.txt | 3 ++ .../attendance_router.cpython-312.pyc | Bin 0 -> 1482 bytes .../__pycache__/auth_router.cpython-312.pyc | Bin 0 -> 987 bytes .../__pycache__/leave_router.cpython-312.pyc | Bin 0 -> 1440 bytes routers/attendance_router.py | 22 +++++++++++++++ routers/auth_router.py | 14 ++++++++++ routers/leave_router.py | 26 ++++++++++++++++++ 9 files changed, 73 insertions(+) create mode 100644 __pycache__/main.cpython-312.pyc create mode 100644 main.py create mode 100644 requirements.txt create mode 100644 routers/__pycache__/attendance_router.cpython-312.pyc create mode 100644 routers/__pycache__/auth_router.cpython-312.pyc create mode 100644 routers/__pycache__/leave_router.cpython-312.pyc create mode 100644 routers/attendance_router.py create mode 100644 routers/auth_router.py create mode 100644 routers/leave_router.py diff --git a/__pycache__/main.cpython-312.pyc b/__pycache__/main.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..dfedd21bbf164b5c41d427ef568fc29de8216141 GIT binary patch literal 698 zcma)3L2J}N82x4^nY6pzZQbZe4}#r7C^SF7Qo5qjf{GUva*<(Yx|=r1#z|7!J^2%Q z^Dk7|gU9^|1uq*|Ss4%&Pu>=K>&cnMv=u7&9X{Th?|W}vGN0=8DyZsNo4p+b@Kckr z%s=3Cs=#|-z)%1o@(|Lv5>!I$;n47m(DY0M72t^BW8+Bq=<*0B+w%p!+Bx1{xXKI6 zOh&rs*gC=mNAM4|ajklW&Hk6#yjERhwZGN-b58x24&oqbJ*G+8e!l5oS)*CndoB7| z%7wf^)09VyMjc)r%>|t9mTb^yUo70!dL+%%PXj(MUF{={w(3qrl34I9e@_}I?Iweo zd+95ymlgx!p1Vu)iN55SGb^nvm5j!|(Em(YMXp2`iV6LAg6MNh<5)KQs1szY%qB^( z`~gnY3Y^_@UnE>4Zj^O;)P2Zz-3PR@qrOh%c0=k%EAjr>%xc(YS-{uCEv3<~oV-zO ziV;Fz;r2IJ&td%ssgG_hj!Eks{tkEo%^aEs_a}BMw_AtZ;mhI12%2Mf^rak*?8S+_ noZHJEpPt+~X`D}AT}%&FC-zcqFCFd;-wu5>{0tkyR=55J6qu?} literal 0 HcmV?d00001 diff --git a/main.py b/main.py new file mode 100644 index 0000000..e03b13e --- /dev/null +++ b/main.py @@ -0,0 +1,8 @@ +from fastapi import FastAPI +from routers import auth_router, attendance_router, leave_router + +app = FastAPI(title="Attendance API") + +app.include_router(auth_router.router, prefix="/auth", tags=["Auth"]) +app.include_router(attendance_router.router, prefix="/attendance", tags=["Attendance"]) +app.include_router(leave_router.router, prefix="/leave", tags=["Leave"]) \ No newline at end of file diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..81a4930 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,3 @@ +fastapi +uvicorn +pydantic \ No newline at end of file diff --git a/routers/__pycache__/attendance_router.cpython-312.pyc b/routers/__pycache__/attendance_router.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..bd8cd06a16173e70fd39e2d0a09488bede9b790f GIT binary patch literal 1482 zcmZ`&O>Epm6rQoYw)eMCQjui&i6|1XlttGY^6uP>t zW27L8x3X~CP|zocXd8$WsJ^A9Zrh~B@=Mv3eTwK?INd@Hg&6s+jfqK3QlzD}MoJrn zarW|a@|5$)XY$A#3aRYNQCT&t>O=WkOBKZrPaI#2`kXSMAEPb-T|IW{)QOM3_Gpj$ zQD|Xd5|>l%cPZG#c{iq?M}!96zB*7=CmOv0-c3Z2jR~@qB}7%K5j+Rp#8RZSs#=<; zEp({2;)jd$e4oZ#sDaCc7DVB>mQ@g@AgW27 zlsJCqxE#7y=rKR!Orl^CfKbEef~Bwt={N);mSAUQm>haxCgBjwW?)-}FMb=uI{H^D zUVdw%wPQ>SCYyg4&3m=_O?A8VXKi6%F6>n5*H7O#bM?%%vxD;NK$}gNUn{1hLj%1r zfskxW?jme9fzmOJ<6Hkj5Qe zPkt`U-YU#B_dO=3Sm^0^Cu1$NUL;>!%vsWq1O|Ii#wW8ad$woJrO)ntCb3EQ@g)#L z6=VDtI(i!&y^mhKk6!z`c<_h%y8c*G@C#SIc#J>|O{AFL*DuvC+jsEf-SHB`VFR`Q51@8GGshpn4${yevfRD9&8laHj5SEqLsuo8&> E0iWbiL;wH) literal 0 HcmV?d00001 diff --git a/routers/__pycache__/auth_router.cpython-312.pyc b/routers/__pycache__/auth_router.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..9263993478f114baf5299a8b6fb1508d1f777d32 GIT binary patch literal 987 zcmZ8f%}*0S6rb6zZVPSsNJK+4#EUK|R8bEmjZqX3BZMdmR|}fqRRFmVHJh4VCMr=~)G8nml2e1)r2$p|_jnV##uw5jhAMPn)LYd46aKjDcys zLUn=bU?@8iP!?ppl09c-uhFIKuw^e$k3fG}7Bv`Ttx`B=HjKeynZ@8?#57QXc3_Xt zZd>Z%jonn|#suqVg)3Ut6%FthYqVfDhYJY^De#Gr)b9e@M)%P?$iqbN!f7bh4N>WE z43;ECQH97vaqw*vwvGf5m1wVH)#jTA*w7~{$q=S^S+GIdFL34T(7E$m4SndglA5&^ z=)nAPI1t&+Q$Skj9`}|k*CBm2ql9{)W4QsWzAb<$mIBj;4Rejq5Vm5-Ob2`{E|}=d zz^n^IAUf`2oxr&o4TBv8U7UGv0oWS)9!qVmuCG2%@5D~M9Q&NfeaPhAYCDlKjK|ade^jlMZ#TM7xxi} kJsnB7%Q6rR~%+gazIq{Ilh5)xXWbPH4UZ zP)mZS#07~%IB-DX(kdJ{B5~o)#n2wy5r`sAzBzSIIq_z9ZAC&zjO_O_JKvl4zW3&r zYPEu3ZJC$1kc!aX(itzKFh&o-I6xFp?4tlTaiBDnKy9j6?kT<&=uI6X1u=YBK$?bv z-bPg2M^t0_Aw-s|X)@!+TyCF~R6oSI4>1&KjJ+17CNpV?m0KDu@9UH36^OHZGD2?C z${6{tI5LJpr%uGMx`u5HB+ynx`OT}BuSIFXxG*j;LP1wAZERe9>tl~~l6Dl@Sd`aE z%-)MA^SzT-7qy|$Yp{EO7;0jQn#v|(D$^)lgWb$hCYCy}G--8p+Yr_jMt0aWb~9yh zA}YT0+@#xK!r+X=Q7FnS9tAEX2@_@#Wk$o+MagwT5-`^l71s?Sn)=eVT=!;5{Njrm zCtS?9E(yaZA+ns8*EaUi9XESCzcEZ%#BF;s&1in`PrE zaB93XFeIm=GawGoEllzD>u_5&DP{!0%u)4w?XW<7im6VGHolH*vvK^)IwPF%dW&qc z)f*ort4RdK488)eur|Z-y^P*h#8eDyq_OKkQ-wiULfXDC^3C1ltRwXz<9eKa5VVs7 zaG2|mnXPbHHkV@<%S`HZz6eTG3xu0-#!thZCC|J7;x>A0F7{42znRYO)3tl*4~>V@ z7kZ@&eQU9|i>vqOcejp^iH&a;o=7E+o;p&%%JTaMJ-}Wl literal 0 HcmV?d00001 diff --git a/routers/attendance_router.py b/routers/attendance_router.py new file mode 100644 index 0000000..567fa64 --- /dev/null +++ b/routers/attendance_router.py @@ -0,0 +1,22 @@ +from fastapi import APIRouter, Header, HTTPException +from datetime import datetime +from pydantic import BaseModel + +router = APIRouter() + +class CheckinRequest(BaseModel): + lat: float + long: float + +@router.post("/checkin") +def check_in(request:CheckinRequest, authorization: str = Header(None),): + print(request) + if authorization != "Bearer fake-jwt-token": + raise HTTPException(status_code=403, detail="Unauthorized") + return {"checked_in_at": datetime.now()} + +@router.post("/checkout") +def check_out(authorization: str = Header(None)): + if authorization != "Bearer fake-jwt-token": + raise HTTPException(status_code=403, detail="Unauthorized") + return {"checked_out_at": datetime.now()} \ No newline at end of file diff --git a/routers/auth_router.py b/routers/auth_router.py new file mode 100644 index 0000000..4f9033a --- /dev/null +++ b/routers/auth_router.py @@ -0,0 +1,14 @@ +from fastapi import APIRouter, HTTPException +from pydantic import BaseModel + +router = APIRouter() + +class LoginRequest(BaseModel): + email: str + password: str + +@router.post("/login") +def login(request: LoginRequest): + if request.email == "test@test.com" and request.password == "1234": + return {"token": "fake-jwt-token"} + raise HTTPException(status_code=401, detail="Invalid credentials") \ No newline at end of file diff --git a/routers/leave_router.py b/routers/leave_router.py new file mode 100644 index 0000000..12c1cbd --- /dev/null +++ b/routers/leave_router.py @@ -0,0 +1,26 @@ +from fastapi import APIRouter, Header, HTTPException +from pydantic import BaseModel + +router = APIRouter() + +class LeaveRequest(BaseModel): + leave_type: str + reason: str + from_date: str + to_date: str + +@router.post("/") +def request_leave(request: LeaveRequest, authorization: str = Header(None)): + if authorization != "Bearer fake-jwt-token": + raise HTTPException(status_code=403, detail="Unauthorized") + return {"status": "Leave request submitted"} + +@router.get("/summary") +def leave_summary(authorization: str = Header(None)): + if authorization != "Bearer fake-jwt-token": + raise HTTPException(status_code=403, detail="Unauthorized") + return { + "sick_leave": 2, + "personal_leave": 3, + "vacation_leave": 1 + } \ No newline at end of file