Run
Flama CLI
We have already seen how to use the command line to run an app in the Quickstart, but we didn't do a proper introduction of the command line interface (CLI). Flama CLI is a convenient tool which is installed automatically with the package, and reduces the hurdles of serving your app.
Once you have a developed app that you want to serve, you need to choose and configure a web server, e.g. gunicorn or uvicorn, and that eventually becomes a repetitive task.
Flama CLI precisely aims at reducing the effort invested in this step to the bare minimum, so that you can focus on developing your app.
Parameters
App path
To be able to serve an app, you need to have a file where you have the following lines:
from flama import Flama
app = Flama()
...As we did in the Quickstart, let's assume that the file containing these lines is main.py, which is located at:
project_folder/āāā src āāā main.py āāā appFor Flama to be able to run the app, it needs to know the exact path to the app variable. The path can be passed directly to the CLI as argument, or by utilising the equivalent environment variable FLAMA_APP. Thus, if we are at project_folder (following the previous example of folder structure), we can run the app by either of the following two ways:
Using option argument
flama run src.main:app
INFO: Started server process [3267]INFO: Waiting for application startup.INFO: Application startup complete.INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)Using environment variable
export FLAMA_APP=src.main:appflama run
INFO: Started server process [3267]INFO: Waiting for application startup.INFO: Application startup complete.INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)Server parameters
Flama CLI uses uvicorn as webserver, and it is because of this that it accepts every argument of the uvicorn CLI:
flama run --help
Usage: flama run [OPTIONS] FLAMA_APP Run a Flama Application based on a route.
<FLAMA_APP> is the route to the Flama object to be served, e.g. 'examples.hello_flama:app'. This can be passed directly as argument of the command line, or by environment variable.āā Options āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā®ā --server-host TEXT āā --server-port INTEGER āā --server-reload āā --server-uds TEXT āā --server-fd INTEGER āā --server-reload-dirs PATH āā --server-reload-includes TEXT āā --server-reload-excludes TEXT āā --server-reload-delay FLOAT āā --server-workers INTEGER āā --server-loop āā --server-http āā --server-ws āā --server-ws-max-size INTEGER āā --server-ws-ping-interval FLOAT āā --server-ws-ping-timeout FLOAT āā --server-ws-per-message-deflate BOOLEAN āā --server-lifespan āā --server-interface āā --server-env-file PATH āā --server-log-config PATH āā --server-log-level āā --server-access-log / --server-no-access-log āā --server-use-colors / --server-no-use-colors āā --server-proxy-headers / --server-no-proxy-headers āā --server-server-header / --server-no-server-header āā --server-date-header / --server-no-date-header āā --server-forwarded-allow-ips TEXT āā --server-root-path TEXT āā --server-limit-concurrency INTEGER āā --server-backlog INTEGER āā --server-limit-max-requests INTEGER āā --server-timeout-keep-alive INTEGER āā --server-ssl-keyfile TEXT āā --server-ssl-certfile TEXT āā --server-ssl-keyfile-password TEXT āā --server-ssl-version INTEGER āā --server-ssl-cert-reqs INTEGER āā --server-ssl-ca-certs TEXT āā --server-ssl-ciphers TEXT āā --server-headers TEXT āā --server-app-dir TEXT āā --server-h11-max-incomplete-event-size INTEGER āā --server-factory āā --help āā°āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāÆFor the exhaustive list of arguments you can pass, and their usage, we recommend you to check here.