Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -124,7 +124,7 @@ def get_human_readable_summary(json_data: dict) -> str:
|
|
| 124 |
You are an expert technical writer. Take the following structured JSON data
|
| 125 |
representing a CV-Job Description match analysis and convert it into a smooth,
|
| 126 |
professional, human-readable summary. Focus on the score, key findings in
|
| 127 |
-
'matching_analysis' and 'description'
|
| 128 |
steps clearly at the end. Do not output any JSON or code formatting.
|
| 129 |
|
| 130 |
JSON Data:
|
|
@@ -290,10 +290,31 @@ app = gr.mount_gradio_app(app, demo, path="/")
|
|
| 290 |
# --- Launch ---
|
| 291 |
if __name__ == "__main__":
|
| 292 |
load_model()
|
| 293 |
-
|
| 294 |
-
port
|
| 295 |
-
|
| 296 |
-
|
| 297 |
-
#
|
| 298 |
-
#
|
| 299 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 124 |
You are an expert technical writer. Take the following structured JSON data
|
| 125 |
representing a CV-Job Description match analysis and convert it into a smooth,
|
| 126 |
professional, human-readable summary. Focus on the score, key findings in
|
| 127 |
+
'matching_analysis' and 'description' and format the 'recommendation'
|
| 128 |
steps clearly at the end. Do not output any JSON or code formatting.
|
| 129 |
|
| 130 |
JSON Data:
|
|
|
|
| 290 |
# --- Launch ---
|
| 291 |
if __name__ == "__main__":
|
| 292 |
load_model()
|
| 293 |
+
|
| 294 |
+
# 1. Determine the primary port from the environment, defaulting to 7860
|
| 295 |
+
primary_port = int(os.environ.get("PORT", 7860))
|
| 296 |
+
|
| 297 |
+
# Define the standard Gradio port as the fallback for robustness
|
| 298 |
+
# Since the logs show PORT=7861 is failing, we try 7860 as the fallback, and vice-versa.
|
| 299 |
+
fallback_port = 7860 if primary_port != 7860 else 7861
|
| 300 |
+
|
| 301 |
+
# Attempt to run on the primary port
|
| 302 |
+
try:
|
| 303 |
+
print(f"Attempting to run Uvicorn on primary port {primary_port}")
|
| 304 |
+
uvicorn.run(app, host="0.0.0.0", port=primary_port)
|
| 305 |
+
|
| 306 |
+
except OSError as e:
|
| 307 |
+
# Check for "Address already in use" (Error code 98)
|
| 308 |
+
if getattr(e, 'errno', None) == 98:
|
| 309 |
+
print(f"ERROR: Primary port {primary_port} is already in use. Trying fallback port {fallback_port}...")
|
| 310 |
+
|
| 311 |
+
# Try running on the fallback port
|
| 312 |
+
try:
|
| 313 |
+
uvicorn.run(app, host="0.0.0.0", port=fallback_port)
|
| 314 |
+
except OSError as fallback_e:
|
| 315 |
+
# If the fallback fails, we must terminate.
|
| 316 |
+
print(f"FATAL ERROR: Fallback port {fallback_port} also failed to bind. Process terminating.")
|
| 317 |
+
raise fallback_e
|
| 318 |
+
else:
|
| 319 |
+
# Re-raise other unexpected errors
|
| 320 |
+
raise e
|