25 lines
575 B
Python
25 lines
575 B
Python
from fastapi import FastAPI
|
|
import sqlite3
|
|
from db.users import get_users, get_attendance
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
|
|
# Get fastapi app
|
|
app = FastAPI()
|
|
|
|
# Add cors headers to the app
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=["http://localhost:3000", "http://127.0.0.1:3000"],
|
|
allow_credentials=True,
|
|
allow_methods=["GET"],
|
|
allow_headers=["*"],
|
|
)
|
|
|
|
@app.get("/")
|
|
def list_users(s: str = None):
|
|
return get_users(s)
|
|
|
|
@app.get("/{employee_id}")
|
|
def list_attendance(employee_id: int):
|
|
return get_attendance(employee_id)
|