Spaces:
Runtime error
Runtime error
macrdel
commited on
Commit
·
2e8e71a
1
Parent(s):
0c25a63
add stats handle
Browse files- app/api.py +9 -1
app/api.py
CHANGED
|
@@ -1,10 +1,12 @@
|
|
| 1 |
import config.config as config
|
| 2 |
-
from app.src.src import pipeline_sentiment
|
| 3 |
|
| 4 |
from fastapi import FastAPI
|
| 5 |
from pydantic import BaseModel
|
| 6 |
from transformers import pipeline
|
| 7 |
import uvicorn
|
|
|
|
|
|
|
| 8 |
|
| 9 |
sentiment_model = pipeline(model=config.sentiment_model)
|
| 10 |
app = FastAPI()
|
|
@@ -22,6 +24,12 @@ def get_comments(url_video: YouTubeUrl):
|
|
| 22 |
data.to_csv(f"{config.DATA_FILE}", index=False)
|
| 23 |
return {'message': 'Success'}
|
| 24 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
|
| 26 |
if __name__ == '__main__':
|
| 27 |
uvicorn.run(app, host='127.0.0.1', port=80)
|
|
|
|
| 1 |
import config.config as config
|
| 2 |
+
from app.src.src import pipeline_sentiment, pipeline_stats
|
| 3 |
|
| 4 |
from fastapi import FastAPI
|
| 5 |
from pydantic import BaseModel
|
| 6 |
from transformers import pipeline
|
| 7 |
import uvicorn
|
| 8 |
+
import pandas as pd
|
| 9 |
+
import os
|
| 10 |
|
| 11 |
sentiment_model = pipeline(model=config.sentiment_model)
|
| 12 |
app = FastAPI()
|
|
|
|
| 24 |
data.to_csv(f"{config.DATA_FILE}", index=False)
|
| 25 |
return {'message': 'Success'}
|
| 26 |
|
| 27 |
+
@app.get('/stats')
|
| 28 |
+
def get_stats_sent():
|
| 29 |
+
if f"{config.NAME_DATA}" in os.listdir(f"{config.PATH_DATA}"):
|
| 30 |
+
data = pd.read_csv(f"{config.DATA_FILE}")
|
| 31 |
+
return pipeline_stats(data)
|
| 32 |
+
|
| 33 |
|
| 34 |
if __name__ == '__main__':
|
| 35 |
uvicorn.run(app, host='127.0.0.1', port=80)
|