TiberiuCristianLeon commited on
Commit
4e5cd58
·
verified ·
1 Parent(s): c1dac64

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -6
app.py CHANGED
@@ -10,14 +10,28 @@ MTMODELS = {'enro': 'BlackKakapo/opus-mt-en-ro',
10
  'roen': 'BlackKakapo/opus-mt-ro-en',
11
  'gemma': 'Gargaz/gemma-2b-romanian-better'}
12
 
13
- # @app.get("/")
14
- # def index():
15
- # return {'endpoints': ['/paraphrase', '/translate', '/docs', 'https://tiberiucristianleon-fastapimt.hf.space/redoc'], 'mtmodels': MTMODELS}
16
-
17
  @app.get("/")
18
- async def get_host_url(request: Request):
 
19
  host_url = request.url.scheme + "://" + request.url.netloc
20
- return {"host_url": host_url, 'endpoints': ['/paraphrase', '/translate', '/docs', 'https://tiberiucristianleon-fastapimt.hf.space/redoc'], 'mtmodels': MTMODELS}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
 
22
  @app.get("/paraphrase")
23
  def paraphrase(text: str, model: str, operation_id="get_paraphrase", description="Paraphrase text"):
 
10
  'roen': 'BlackKakapo/opus-mt-ro-en',
11
  'gemma': 'Gargaz/gemma-2b-romanian-better'}
12
 
 
 
 
 
13
  @app.get("/")
14
+ def index(request: Request):
15
+ from fastapi.responses import HTMLResponse
16
  host_url = request.url.scheme + "://" + request.url.netloc
17
+ html_content = f'''
18
+ <html>
19
+ <head>
20
+ <title>Welcome</title>
21
+ </head>
22
+ <body>
23
+ <h1>FastAPI with MCP</h1>
24
+ <p>Host URL: {host_url}</p>
25
+ <a href="{host_url}/docs">DOCS</a>
26
+ </body>
27
+ </html>
28
+ '''
29
+ return HTMLResponse(content=html_content)
30
+
31
+ # @app.get("/")
32
+ # async def get_host_url(request: Request):
33
+ # host_url = request.url.scheme + "://" + request.url.netloc
34
+ # return {"host_url": host_url, 'endpoints': ['/paraphrase', '/translate', f'{host_url}/docs', f'{host_url}/redoc', f'{host_url}/openapi.json'], 'mtmodels': MTMODELS}
35
 
36
  @app.get("/paraphrase")
37
  def paraphrase(text: str, model: str, operation_id="get_paraphrase", description="Paraphrase text"):