from fastapi import FastAPI
import uvicorn

app = FastAPI()

@app.post("/sort")
async def sort(word_count_dict: dict):
    sorted_word_count = sorted(word_count_dict["word_count"].items(), key=lambda x: x[1], reverse=True)
    top_10_words = sorted_word_count[:10]
    return {"top_10_words": top_10_words}

if __name__ == "__main__":
    uvicorn.run(app, host="127.0.0.1", port= 7772)