Spaces:
Sleeping
Sleeping
Commit
路
4449ca6
1
Parent(s):
ef911a2
Fix: Update README.md and app.py for proper HF Spaces configuration
Browse files- Add app_port: 7860 to README.md frontmatter
- Enhance FastAPI app with HTML homepage
- Add health check and improved API endpoints
- Better documentation and user experience
README.md
CHANGED
|
@@ -4,8 +4,23 @@ emoji: 馃
|
|
| 4 |
colorFrom: purple
|
| 5 |
colorTo: green
|
| 6 |
sdk: docker
|
|
|
|
| 7 |
pinned: false
|
| 8 |
-
short_description:
|
| 9 |
---
|
| 10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
| 4 |
colorFrom: purple
|
| 5 |
colorTo: green
|
| 6 |
sdk: docker
|
| 7 |
+
app_port: 7860
|
| 8 |
pinned: false
|
| 9 |
+
short_description: Scientific research FastAPI application
|
| 10 |
---
|
| 11 |
|
| 12 |
+
# Sciresearch
|
| 13 |
+
|
| 14 |
+
Scientific research FastAPI application deployed on Hugging Face Spaces.
|
| 15 |
+
|
| 16 |
+
## Features
|
| 17 |
+
|
| 18 |
+
- FastAPI web application
|
| 19 |
+
- Docker-based deployment
|
| 20 |
+
- Simple API endpoints
|
| 21 |
+
|
| 22 |
+
## API Endpoints
|
| 23 |
+
|
| 24 |
+
- `GET /` - Returns a greeting message
|
| 25 |
+
|
| 26 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
app.py
CHANGED
|
@@ -1,7 +1,55 @@
|
|
| 1 |
from fastapi import FastAPI
|
|
|
|
| 2 |
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
|
| 5 |
-
@app.get("/")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
def greet_json():
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
from fastapi import FastAPI
|
| 2 |
+
from fastapi.responses import HTMLResponse
|
| 3 |
|
| 4 |
+
# Crear la aplicaci贸n FastAPI
|
| 5 |
+
app = FastAPI(
|
| 6 |
+
title="SciResearch API",
|
| 7 |
+
description="Scientific Research FastAPI application on Hugging Face Spaces",
|
| 8 |
+
version="1.0.0"
|
| 9 |
+
)
|
| 10 |
|
| 11 |
+
@app.get("/", response_class=HTMLResponse)
|
| 12 |
+
def read_root():
|
| 13 |
+
"""
|
| 14 |
+
Endpoint principal que devuelve una p谩gina HTML simple
|
| 15 |
+
"""
|
| 16 |
+
html_content = """
|
| 17 |
+
<!DOCTYPE html>
|
| 18 |
+
<html>
|
| 19 |
+
<head>
|
| 20 |
+
<title>SciResearch API</title>
|
| 21 |
+
<style>
|
| 22 |
+
body { font-family: Arial, sans-serif; margin: 40px; }
|
| 23 |
+
h1 { color: #333; }
|
| 24 |
+
.container { max-width: 600px; margin: 0 auto; }
|
| 25 |
+
</style>
|
| 26 |
+
</head>
|
| 27 |
+
<body>
|
| 28 |
+
<div class="container">
|
| 29 |
+
<h1>馃 SciResearch API</h1>
|
| 30 |
+
<p>隆Bienvenido a la aplicaci贸n de investigaci贸n cient铆fica!</p>
|
| 31 |
+
<h2>Endpoints disponibles:</h2>
|
| 32 |
+
<ul>
|
| 33 |
+
<li><a href="/docs">/docs</a> - Documentaci贸n interactiva de la API</li>
|
| 34 |
+
<li><a href="/api/hello">/api/hello</a> - Saludo JSON</li>
|
| 35 |
+
<li><a href="/api/health">/api/health</a> - Estado de la aplicaci贸n</li>
|
| 36 |
+
</ul>
|
| 37 |
+
</div>
|
| 38 |
+
</body>
|
| 39 |
+
</html>
|
| 40 |
+
"""
|
| 41 |
+
return html_content
|
| 42 |
+
|
| 43 |
+
@app.get("/api/hello")
|
| 44 |
def greet_json():
|
| 45 |
+
"""
|
| 46 |
+
Endpoint que devuelve un saludo en formato JSON
|
| 47 |
+
"""
|
| 48 |
+
return {"message": "隆Hola mundo desde SciResearch!", "status": "success"}
|
| 49 |
+
|
| 50 |
+
@app.get("/api/health")
|
| 51 |
+
def health_check():
|
| 52 |
+
"""
|
| 53 |
+
Endpoint para verificar el estado de la aplicaci贸n
|
| 54 |
+
"""
|
| 55 |
+
return {"status": "healthy", "service": "sciresearch", "version": "1.0.0"}
|