Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Run and manage FastAPI apps from the command line with FastAPI CLI. 🚀

License

NotificationsYou must be signed in to change notification settings

fastapi/fastapi-cli

Repository files navigation

TestPublishCoveragePackage version

Source Code:https://github.com/fastapi/fastapi-cli


Run and manage FastAPI apps from the command line with FastAPI CLI. 🚀

Description

FastAPI CLI is a command line programfastapi that you can use to serve your FastAPI app, manage your FastAPI project, and more.

When you install FastAPI (e.g. withpip install "fastapi[standard]"), it includes a package calledfastapi-cli, this package provides thefastapi command in the terminal.

To run your FastAPI app for development, you can use thefastapi dev command:

$fastapi dev main.py   FastAPI   Starting development server 🚀             Searching for package file structure from directories with __init__.py files             Importing from /home/user/code/awesomeapp    module   🐍 main.py      code   Importing the FastAPI app object from the module with the following code:             from main import app       app   Using import string: main:app    server   Server started at http://127.0.0.1:8000    server   Documentation at http://127.0.0.1:8000/docs       tip   Running in development mode, for production use: fastapi run             Logs:      INFO   Will watch for changes in these directories: ['/home/user/code/awesomeapp']      INFO   Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)      INFO   Started reloader process [4106097] using WatchFiles      INFO   Started server process [4106120]      INFO   Waiting for application startup.      INFO   Application startup complete.

That command line program calledfastapi isFastAPI CLI.

FastAPI CLI takes the path to your Python program and automatically detects the variable with the FastAPI (commonly namedapp) and how to import it, and then serves it.

For production you would usefastapi run instead. 🚀

Internally,FastAPI CLI usesUvicorn, a high-performance, production-ready, ASGI server. 😎

fastapi dev

When you runfastapi dev, it will run on development mode.

By default, it will haveauto-reload enabled, so it will automatically reload the server when you make changes to your code. This is resource intensive and could be less stable than without it, you should only use it for development.

By default it will listen on the IP address127.0.0.1, which is the IP for your machine to communicate with itself alone (localhost).

fastapi run

When you runfastapi run, it will run on production mode by default.

It will haveauto-reload disabled by default.

It will listen on the IP address0.0.0.0, which means all the available IP addresses, this way it will be publicly accessible to anyone that can communicate with the machine. This is how you would normally run it in production, for example, in a container.

In most cases you would (and should) have a "termination proxy" handling HTTPS for you on top, this will depend on how you deploy your application, your provider might do this for you, or you might need to set it up yourself. You can learn more about it in theFastAPI Deployment documentation.

License

This project is licensed under the terms of the MIT license.

About

Run and manage FastAPI apps from the command line with FastAPI CLI. 🚀

Topics

Resources

License

Security policy

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp