简体   繁体   中英

How to call a FastAPI route from NodeJS?

this is my FasiAPI route:

@app.post("/files/")
async def create_file(file: UploadFile = Form(...)):
    #some ml code
    return {'detected_face': base64_return, 'feature_vector': str(embedded)}

My webapp backend is running on NodeJs + ExpressJS. I have the file store in './uploads/filename.jpeg'

FastAPI is running on: localhost:8000

Web backend server running on: localhost:3000

Thanks in advance!

You can send request directly through url: localhost:8000/ by using request module.

request('http://localhost:8000/files/<parameter>', function (error, response, body) {
    if (!error && response.statusCode == 200) {
        console.log(body)
    }
})

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM