Huseyin Kir commited on
Commit
787b56a
·
1 Parent(s): 210d485

root endpoint updated

Browse files
Files changed (1) hide show
  1. app.py +52 -1
app.py CHANGED
@@ -1,6 +1,6 @@
1
  import os
2
  from fastapi import FastAPI, HTTPException
3
- from fastapi.responses import StreamingResponse
4
  import lancedb
5
  from sentence_transformers import SentenceTransformer
6
  from huggingface_hub import snapshot_download
@@ -153,4 +153,55 @@ def generate_download_info(record: dict) -> list:
153
  return get_folder_file_urls(data_file)
154
  else:
155
  return []
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
156
 
 
1
  import os
2
  from fastapi import FastAPI, HTTPException
3
+ from fastapi.responses import StreamingResponse, HTMLResponse
4
  import lancedb
5
  from sentence_transformers import SentenceTransformer
6
  from huggingface_hub import snapshot_download
 
153
  return get_folder_file_urls(data_file)
154
  else:
155
  return []
156
+
157
+
158
+ # Root endpoint with HTML response
159
+ @app.get("/", response_class=HTMLResponse, include_in_schema=False)
160
+ def root():
161
+ return """
162
+ <!DOCTYPE html>
163
+ <html>
164
+ <head>
165
+ <title>NDL Core Data API</title>
166
+ <style>
167
+ body {
168
+ font-family: Arial, sans-serif;
169
+ max-width: 720px;
170
+ margin: 40px auto;
171
+ line-height: 1.6;
172
+ }
173
+ code {
174
+ background: #f4f4f4;
175
+ padding: 2px 6px;
176
+ border-radius: 4px;
177
+ }
178
+ </style>
179
+ </head>
180
+ <body>
181
+ <h1>NDL Core Data API</h1>
182
+ <p>
183
+ This Space provides a <strong>FastAPI-based service</strong> for semantic search
184
+ and data download across NDL Core datasets.
185
+ </p>
186
+
187
+ <h3>Key Endpoints</h3>
188
+ <ul>
189
+ <li><code>GET /search</code> – Semantic search over NDL Core datasets</li>
190
+ <li><code>GET /download/text/{identifier}</code> – Download dataset text files</li>
191
+ </ul>
192
+
193
+ <p>
194
+ For detailed usage examples, parameters, and data definitions,
195
+ see the full project README:
196
+ </p>
197
+
198
+ <p>
199
+ 👉 <a href="https://huggingface.co/spaces/theodi/ndl-core-data-api/blob/main/README.md" target="_blank">
200
+ Project README
201
+ </a>
202
+ </p>
203
+ </body>
204
+ </html>
205
+ """
206
+
207