/I model/
from pymongo import MongoClient
from pydantic import BaseModel
from fastapi import FastAPI,Request
from typing import List
from fastapi.templating import Jinja2Templates from fastapi.staticfiles import StaticFiles
app = FastAPI() templates = Jinja2Templates('/root/py/templates')
app.mount('/static', StaticFiles(directory='/root/py/static'), name='static')
def get_top():
DB = "slack"
MSG_COLLECTION = "messages"
url="mongodb://localhost:27017/"
client_link=MongoClient(url)[DB][MSG_COLLECTION]
return client_link
class Message(BaseModel):
channel: str
author: str
text: str
@app.get("/")
async def home(request: Request):
doc=mydoc.find().distinct('channel')+mydo
c.find().distinct('text')+mydoc.find().distinct('author')
data_all={"request":request, "doc":doc, }
return templates.TemplateResponse("index.html",data_all)
/Looking for a js solution, do not nodejs , I don't understand nodejs code, thank you, ask for a solution. For example, I want to delete 'channel': 'jo', how to write fastapi and js respectively?/