How to run FastAPI from terminal?

Viewed 1876

I want to execute fastapi in shell.
for example, we can do it with below code in django:
python manage.py shell
how can I do this in fastapi?

3 Answers

Simple answer, You can not.

manage.py does the same thing as django-admin but also sets the DJANGO_SETTINGS_MODULE environment variable so that it points to your project’s settings.py file. In FastAPI we don't have admin utility, because there is no out-of-box config, environment management etc. That's the main difference between a microframework and a high-level framework.

FastAPI does not have any administration utilities out-of-box.

In terminal go to directory where your main.py is and type

uvicorn main:app --host 0.0.0.0 --port 8888

enter image description hereYou cannot do that, But by running python in the terminal and importing proper functions and packages you can do most of the essential tasks like debugging your function

Related