1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/FastAPI_ynh.git synced 2024-09-03 18:36:00 +02:00

définition du root_path via uvicorn

This commit is contained in:
leonard 2023-12-08 15:03:41 +01:00 committed by Leonard
parent 16063a02c1
commit ed93274433
4 changed files with 13 additions and 2 deletions

View file

@ -1,9 +1,12 @@
import os
from typing import Union from typing import Union
from fastapi import FastAPI from fastapi import FastAPI
app = FastAPI(root_path="__PATH__") UVICORN_ROOT_PATH = os.environ.get('UVICORN_ROOT_PATH')
#app = FastAPI(root_path=UVICORN_ROOT_PATH)
app = FastAPI()
@app.get("/") @app.get("/")
def read_root(): def read_root():

View file

@ -7,6 +7,9 @@ User=__APP__
Group=__APP__ Group=__APP__
WorkingDirectory=__DATA_DIR__/ WorkingDirectory=__DATA_DIR__/
# UVICORN_ROOT_PATH is used by FastAPI to serve the 'docs' page correctly
Environment="UVICORN_ROOT_PATH=__PATH__"
ExecStart=__INSTALL_DIR__/venv/bin/gunicorn --config __INSTALL_DIR__/gunicorn.conf.py FastAPIAppFolder:app --worker-class uvicorn.workers.UvicornWorker ExecStart=__INSTALL_DIR__/venv/bin/gunicorn --config __INSTALL_DIR__/gunicorn.conf.py FastAPIAppFolder:app --worker-class uvicorn.workers.UvicornWorker
StandardOutput=syslog StandardOutput=syslog

View file

@ -25,6 +25,11 @@ ynh_script_progression --message="Updating NGINX web server configuration..." --
ynh_change_url_nginx_config ynh_change_url_nginx_config
ynh_script_progression --message="Updating systemd service..." --weight=1
ynh_add_systemd_config
#================================================= #=================================================
# GENERIC FINALISATION # GENERIC FINALISATION
#================================================= #=================================================

View file

@ -47,7 +47,7 @@ ynh_add_config --template="gunicorn.conf.py" --destination="$install_dir/gunicor
mkdir -p "$data_dir/FastAPIAppFolder" mkdir -p "$data_dir/FastAPIAppFolder"
ynh_add_config --template="__init__.py" --destination="$data_dir/FastAPIAppFolder/__init__.py" ynh_add_config --template="__init__.py" --destination="$data_dir/FastAPIAppFolder/__init__.py"
ynh_app_setting_set --app=$app --key=main_folder --value="FastAPIAppFolder" ynh_app_setting_set --app=$app --key=main_folder --value="FastAPIAppFolder"
ynh_app_setting_set --app=$app --key=requirements --value=0 ynh_app_setting_set --app=$app --key=requirements_path --value=""
# Add the password to this user # Add the password to this user
chpasswd <<< "${app}:${password}" chpasswd <<< "${app}:${password}"