Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
from fastapi import FastAPI
|
| 2 |
import src.Paraphrase as Paraphrase
|
| 3 |
import src.Translate as Translate
|
| 4 |
from typing import Optional
|
|
@@ -14,6 +14,11 @@ MTMODELS = {'enro': 'BlackKakapo/opus-mt-en-ro',
|
|
| 14 |
# def index():
|
| 15 |
# return {'endpoints': ['/paraphrase', '/translate', '/docs', 'https://tiberiucristianleon-fastapimt.hf.space/redoc'], 'mtmodels': MTMODELS}
|
| 16 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
@app.get("/paraphrase")
|
| 18 |
def paraphrase(text: str, model: str, operation_id="get_paraphrase", description="Paraphrase text"):
|
| 19 |
resultValue, exception = Paraphrase.paraphraseParaphraseMethod(text, model)
|
|
|
|
| 1 |
+
from fastapi import FastAPI, Request
|
| 2 |
import src.Paraphrase as Paraphrase
|
| 3 |
import src.Translate as Translate
|
| 4 |
from typing import Optional
|
|
|
|
| 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"):
|
| 24 |
resultValue, exception = Paraphrase.paraphraseParaphraseMethod(text, model)
|