Code Monkey home page Code Monkey logo

fastapi-cli's Introduction

FastAPI CLI

Test Publish Coverage Package 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 program fastapi that you can use to serve your FastAPI app, manage your FastAPI project, and more.

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

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

$ fastapi dev main.py
INFO     Using path main.py
INFO     Resolved absolute path /home/user/code/awesomeapp/main.py
INFO     Searching for package file structure from directories with __init__.py files
INFO     Importing from /home/user/code/awesomeapp

 โ•ญโ”€ Python module file โ”€โ•ฎ
 โ”‚                      โ”‚
 โ”‚  ๐Ÿ main.py          โ”‚
 โ”‚                      โ”‚
 โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

INFO     Importing module main
INFO     Found importable FastAPI app

 โ•ญโ”€ Importable FastAPI app โ”€โ•ฎ
 โ”‚                          โ”‚
 โ”‚  from main import app    โ”‚
 โ”‚                          โ”‚
 โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

INFO     Using import string main:app

 โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ FastAPI CLI - Development mode โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
 โ”‚                                                     โ”‚
 โ”‚  Serving at: http://127.0.0.1:8000                  โ”‚
 โ”‚                                                     โ”‚
 โ”‚  API docs: http://127.0.0.1:8000/docs               โ”‚
 โ”‚                                                     โ”‚
 โ”‚  Running in development mode, for production use:   โ”‚
 โ”‚                                                     โ”‚
 โ”‚  fastapi run                                        โ”‚
 โ”‚                                                     โ”‚
 โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

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 [56345] using WatchFiles
INFO:     Started server process [56352]
INFO:     Waiting for application startup.
INFO:     Application startup complete.

That command line program called fastapi is FastAPI CLI.

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

For production you would use fastapi run instead. ๐Ÿš€

Internally, FastAPI CLI uses Uvicorn, a high-performance, production-ready, ASGI server. ๐Ÿ˜Ž

fastapi dev

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

By default, it will have auto-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 address 127.0.0.1, which is the IP for your machine to communicate with itself alone (localhost).

fastapi run

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

It will have auto-reload disabled by default.

It will listen on the IP address 0.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 the FastAPI Deployment documentation.

License

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

fastapi-cli's People

Contributors

tiangolo avatar dependabot[bot] avatar patrick91 avatar pedroimpulcetto avatar pokkakiyo avatar pre-commit-ci[bot] avatar

Stargazers

 avatar Unchun Yang avatar Matheus Mendes avatar Thecode764[bot] avatar Shitty Girl avatar Sofie Van Landeghem avatar Lance Peterson  avatar Francisco Griman avatar  avatar  avatar Sebastiรกn Garcรญa avatar Irfan M. Chatha โœ… avatar Berserk avatar Aldiansyah Fandevtian avatar Vitor Schirmer avatar Lukash avatar Leon avatar Igor Petrov avatar Andrรฉs Segura avatar noynovera avatar  avatar  avatar  avatar Yudhi Kandel avatar Ted Lin avatar Arvid avatar Minh Quan Do avatar Jesรบs Alexis Torreblanca Faces avatar allen.hu avatar Mustafa Alp YANIKOฤžLU avatar Juan Esteban Escobar Restrepo avatar Mohammad Amin Amjadi avatar Kevin Liu avatar Yves Marinho avatar David Urbina avatar  avatar  avatar Matheus avatar Gabriel Dumitrescu avatar Edward Gรณmez avatar Calcagno Loรฏc avatar KALAGA Serge Eric avatar Sofia Oliveira avatar Inayet Hadi  avatar Abhishek avatar Nattaphoom Chaipreecha avatar Djemmal Islam avatar Jonathan Dominguez avatar  avatar Daniel Santa Cruz avatar Deight avatar Sebastian avatar Theodore Georgomanolis avatar  avatar Andreu Codina avatar james yang avatar Rafael Izidoro avatar Dmitry Kulikov avatar Joรฃo Victor avatar  avatar Alan Goo avatar Roy Adventus avatar dipendra pandey avatar Pratik Mehta avatar vidya sagar avatar Armando Urquiola Cabrera avatar ReL Rail avatar Ilya Katun avatar Stevan Vlajic avatar  avatar mikigo avatar Akim Faskhutdinov avatar Ahsen avatar Robert Richter avatar  avatar Ahmed Rakan Aldhafeeri avatar Ezo Saleh avatar Devansh Parapalli avatar John Safrit avatar Matheus Mello de Lima avatar Bernardo Gomes avatar Filippo Giunchedi avatar  avatar  avatar Matteo Bigoi avatar Adebayo Akinlalu avatar  avatar  avatar HG avatar Matt Barkway avatar HaochengLian avatar Morteza mousakhani avatar humphrey avatar Ali avatar Hak-Init avatar X Wang avatar immelon avatar Hamza avatar Bruno Melo avatar Amine Djeghri avatar

Watchers

 avatar Hudson Brendon avatar Esteban Maya avatar Syed Furqan Ali Shah avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.