Commit 2bce8044 authored by Prateek Lal's avatar Prateek Lal
parents a73a09e7 79fb0e78
from fastapi import APIRouter, HTTPException
from fastapi.responses import FileResponse
from pydantic import BaseModel
import os
router = APIRouter()
# Define a Pydantic model for the data we expect in the POST request
class InputData(BaseModel):
jobTitle: str
department: str
jobDescription: str
# POST endpoint
@router.post("/submit/")
async def submit_data(data: InputData):
# Here, you can process the data (e.g., save it to a database)
return {"message": "Data received successfully!", "data": data.dict()}
@router.get("/read-file")
async def read_file(file_path: str):
# Define the base directory for public files
base_dir = "/path/to/public/drive"
# Construct the full file path
full_path = os.path.join(base_dir, file_path)
# Check if the file exists
if not os.path.isfile(full_path):
raise HTTPException(status_code=404, detail="File not found")
# Return the file as a response
return FileResponse(full_path)
@router.get("/hello")
async def hello_world():
return {"message": "Hello, World!"}
\ No newline at end of file
import streamlit as st
import requests
# FastAPI URL (assuming it is running locally on port 8000)
API_URL = "http://127.0.0.1:8000/submit/"
# Title of the app
st.title("Enter JD to fetch resumes!")
......@@ -11,9 +15,17 @@ job_description = st.text_area("Job Description", height=200)
# Add a submit button
if st.button("Submit"):
if job_title and department and job_description:
st.success("Job Description Submitted Successfully!")
st.write(f"**Job Title:** {job_title}")
st.write(f"**Department:** {department}")
st.write(f"**Job Description:** {job_description}")
else:
st.error("Please fill in all the fields.")
data = {
"jobTitle": job_title,
"department": department,
"jobDescription": job_description
}
response = requests.post(API_URL, json=data)
# If the request is successful, display the response
if response.status_code == 200:
result = response.json()
st.success(result['message'])
st.write("Received Data:", result['data'])
else:
st.error(f"Error: {response.status_code}")
else:
\ No newline at end of file
from fastapi import FastAPI
from src.api import router
app = FastAPI()
app.include_router(router)
if __name__ == "__main__":
import uvicorn
uvicorn.run(app, host="0.0.0.0", port=8000)
\ No newline at end of file
......@@ -3,4 +3,7 @@ PyPDF2
scikit-learn
transformers
streamlit
fastapi
uvicorn
requests
router
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment