{"Posit Workbench FastAPI Uvicorn Root Path Snippet":{"prefix":"from fastapi import FastAPI","body":["from fastapi import FastAPI","import os","import uvicorn","","app = FastAPI()","","if __name__ == '__main__':","    path, port = '$2', ${1:8000} # declare uvicorn arguments","","    # When running in Posit Workbench, pass port to rserver-url to determine the root path","    # See https://docs.posit.co/ide/server-pro/user/vs-code/guide/posit-workbench-extension.html#fastapi for details","    if 'RS_SERVER_URL' in os.environ and os.environ['RS_SERVER_URL']:","        import subprocess","        path = subprocess.run(f'echo $(/usr/lib/rstudio-server/bin/rserver-url -l {port})',","                              stdout=subprocess.PIPE, shell=True).stdout.decode().strip()","    uvicorn.run(app, port = port, root_path = path)"],"description":"Insert Posit Workbench Uvicorn custom port wrapper"},"Posit Workbench Uvicorn Root Path Snippet":{"prefix":"uvicorn.run(","body":["path, port = '$2', ${1:8000} # declare uvicorn arguments","","# When running in Posit Workbench, pass port to rserver-url to determine the root path","# See https://docs.posit.co/ide/server-pro/user/vs-code/guide/posit-workbench-extension.html#fastapi for details","import os","if 'RS_SERVER_URL' in os.environ and os.environ['RS_SERVER_URL']:","    import subprocess","    path = subprocess.run(f'echo $(/usr/lib/rstudio-server/bin/rserver-url -l {port})',","                          stdout=subprocess.PIPE, shell=True).stdout.decode().strip()","uvicorn.run(app, port = port, root_path = path)"]},"Posit Workbench Flask Interface":{"prefix":"from flask import Flask","body":["from flask import Flask","import os","","app = Flask(__name__)","","# When running in Posit Workbench, apply ProxyFix middleware","# See: https://docs.posit.co/ide/server-pro/user/vs-code/guide/posit-workbench-extension.html#flask","if 'RS_SERVER_URL' in os.environ and os.environ['RS_SERVER_URL']:","    from werkzeug.middleware.proxy_fix import ProxyFix","    app.wsgi_app = ProxyFix(app.wsgi_app, x_prefix=1)"],"description":"Insert Posit Workbench Proxy Code"}}