Commit 79fb0e78 authored by Prayas Jain's avatar Prayas Jain

Intgegrate api with submit button

parent 4380067b
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
......
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,18 @@ 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}")
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:
st.error("Please fill in all the fields.")
\ No newline at end of file
st.warning("Please fill in all the fields!")
\ No newline at end of file
......@@ -4,4 +4,6 @@ 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