MK Fast
MK Fast

Reputation: 528

How to run FastAPI in shell mode?

I want to execute FastAPI in shell.
For example, we can do it with the below code in Django:

python manage.py shell

How can I do this in FastAPI?

Upvotes: 7

Views: 7814

Answers (4)

Ahmed Amer
Ahmed Amer

Reputation: 114

You can use debug console offerd by your IDE, if you're using VScode you can simple configure your launch.json like:

"configurations": [
    {
        "name": "FastApi Server",
        "type": "python",
        "request": "launch",
        "module": "uvicorn",
        "args": [
            "main:app",
            "--reload"
        ],
        "jinja": true,
        "justMyCode": false
    }
]

Upvotes: -1

shubham goyal
shubham goyal

Reputation: 329

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

Upvotes: -1

alif
alif

Reputation: 123

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

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

Upvotes: 0

Yagiz Degirmenci
Yagiz Degirmenci

Reputation: 20598

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.

Upvotes: 3

Related Questions