Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,4 +1,16 @@
|
|
|
|
|
| 1 |
import gradio as gr
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
def bulletify(text_string, prefix="- "):
|
| 4 |
"""
|
|
@@ -130,4 +142,35 @@ demo = gr.Interface(
|
|
| 130 |
title="CV Template with Markdown Tables + Bullets"
|
| 131 |
)
|
| 132 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 133 |
demo.launch(server_name="0.0.0.0", server_port=7860, share=True)
|
|
|
|
| 1 |
+
from fastapi import FastAPI, Request
|
| 2 |
import gradio as gr
|
| 3 |
+
from fastapi.middleware.cors import CORSMiddleware
|
| 4 |
+
|
| 5 |
+
app = FastAPI()
|
| 6 |
+
|
| 7 |
+
# Add CORS middleware to allow requests from Make.com or Postman
|
| 8 |
+
app.add_middleware(
|
| 9 |
+
CORSMiddleware,
|
| 10 |
+
allow_origins=["*"], # Allow all origins (you can restrict this in production)
|
| 11 |
+
allow_methods=["POST"],
|
| 12 |
+
allow_headers=["*"],
|
| 13 |
+
)
|
| 14 |
|
| 15 |
def bulletify(text_string, prefix="- "):
|
| 16 |
"""
|
|
|
|
| 142 |
title="CV Template with Markdown Tables + Bullets"
|
| 143 |
)
|
| 144 |
|
| 145 |
+
# FastAPI endpoint for POST requests
|
| 146 |
+
@app.post("/run/predict")
|
| 147 |
+
async def predict(request: Request):
|
| 148 |
+
data = await request.json()
|
| 149 |
+
cv_output = generate_cv(
|
| 150 |
+
email=data.get("email"),
|
| 151 |
+
date_of_birth=data.get("date_of_birth"),
|
| 152 |
+
mbti=data.get("mbti"),
|
| 153 |
+
sustainable_dev_goals=data.get("sustainable_dev_goals"),
|
| 154 |
+
via_strengths=data.get("via_strengths"),
|
| 155 |
+
disc_d=data.get("disc_d"),
|
| 156 |
+
disc_i=data.get("disc_i"),
|
| 157 |
+
disc_s=data.get("disc_s"),
|
| 158 |
+
disc_c=data.get("disc_c"),
|
| 159 |
+
big5_openness=data.get("big5_openness"),
|
| 160 |
+
big5_conscientiousness=data.get("big5_conscientiousness"),
|
| 161 |
+
big5_extraversion=data.get("big5_extraversion"),
|
| 162 |
+
big5_agreeableness=data.get("big5_agreeableness"),
|
| 163 |
+
big5_emotional_stability=data.get("big5_emotional_stability"),
|
| 164 |
+
past_project=data.get("past_project"),
|
| 165 |
+
influences=data.get("influences"),
|
| 166 |
+
main_passions=data.get("main_passions"),
|
| 167 |
+
preferred_location=data.get("preferred_location"),
|
| 168 |
+
ideal_work_environment=data.get("ideal_work_environment"),
|
| 169 |
+
productive_time=data.get("productive_time"),
|
| 170 |
+
partner_qualities=data.get("partner_qualities"),
|
| 171 |
+
vision=data.get("vision")
|
| 172 |
+
)
|
| 173 |
+
return {"cv_output": cv_output}
|
| 174 |
+
|
| 175 |
+
# Launch Gradio and FastAPI
|
| 176 |
demo.launch(server_name="0.0.0.0", server_port=7860, share=True)
|