Update app.py
Browse files
app.py
CHANGED
@@ -1,25 +1,21 @@
|
|
1 |
from fastapi import FastAPI, Query
|
2 |
-
from
|
3 |
|
4 |
app = FastAPI()
|
5 |
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
|
|
8 |
"""
|
9 |
-
|
10 |
"""
|
11 |
-
|
12 |
-
sentiment = blob.sentiment.polarity
|
13 |
-
|
14 |
-
if sentiment > 0:
|
15 |
-
sentiment_label = "positivo"
|
16 |
-
elif sentiment < 0:
|
17 |
-
sentiment_label = "negativo"
|
18 |
-
else:
|
19 |
-
sentiment_label = "neutro"
|
20 |
-
|
21 |
return {
|
22 |
-
"
|
23 |
-
"
|
24 |
-
"
|
|
|
25 |
}
|
|
|
1 |
from fastapi import FastAPI, Query
|
2 |
+
from forex_python.converter import CurrencyRates
|
3 |
|
4 |
app = FastAPI()
|
5 |
|
6 |
+
currency_rates = CurrencyRates()
|
7 |
+
|
8 |
+
@app.get("/convert/")
|
9 |
+
def convert_currency(amount: float = Query(..., description="Quantia a ser convertida"),
|
10 |
+
from_currency: str = Query(..., description="Moeda de origem"),
|
11 |
+
to_currency: str = Query(..., description="Moeda de destino")):
|
12 |
"""
|
13 |
+
Converte uma quantia de uma moeda para outra.
|
14 |
"""
|
15 |
+
converted_amount = currency_rates.convert(from_currency, to_currency, amount)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
return {
|
17 |
+
"amount": amount,
|
18 |
+
"from_currency": from_currency,
|
19 |
+
"to_currency": to_currency,
|
20 |
+
"converted_amount": converted_amount
|
21 |
}
|