Home > Blockchain >  Testing FastAPI endpoints in the interface
Testing FastAPI endpoints in the interface

Time:01-07

I got access to a private GitLab project that contains the following branches: main, develop and new_branch. The machine learning project is pretty complex and contains various transformers for NLP, and many steps that generate some output from an input text. FastAPI has also been used. I am using Windows.

I followed the instructions and ran pipenv run start:

←[32mINFO←[0m:     Started server process [←[36m12988←[0m]
←[32mINFO←[0m:     Waiting for application startup.
←[32mINFO←[0m:     Application startup complete.
←[32mINFO←[0m:     Uvicorn running on ←[1mhttp://127.0.0.1:8000←[0m (Press CTRL C to quit)

I go to http://127.0.0.1:8000 and get (though the instructions say to go to http://localhost:8000/):

{"name":"my app API","version":"0.0.1","currentTime":"01/07/2022, 04:41:36"}

And in the terminal:

←[32mINFO←[0m:     127.0.0.1:65248 - "←[1mGET / HTTP/1.1←[0m" ←[32m200 OK←[0m

But how do I actually play around with the app? I saw a simple example on the internet where I navigate to the endpoint in the browser, but in my case the project is much more complicated and the tree of the folder is huge. Anything that I type after the address in browser, it gives me {"detail":"Not Found"}.

CodePudding user response:

Since FastAPI is simply a framework for creating APIs, there is no real user interface available (aside from the documentation it generates). It's not a web app - just a collection of endpoint definitions.

From the FastAPI documentation:

Interactive API docs

Alternative API docs

If you want to know what endpoints are available in the application, try going to http://127.0.0.1:8080/docs or http://127.0.0.1:8080/redoc.

  •  Tags:  
  • Related