Skip to content

Compile FastAPI Project in reload mode #8092

Closed Answered by rokm
krunaldodiya asked this question in PyInstaller
Discussion options

You must be logged in to vote

Is it possible to run fastapi binary using uvicorn ?

Your example works for me:

# hello.py
from fastapi import FastAPI

app = FastAPI()

@app.get("/")
async def home():
    return {"success": True}
# run.py
# freeze with: pyinstaller --clean --noconfirm --onefile --hiddenimport hello run.py
import multiprocessing
import uvicorn

if __name__ == "__main__":
    multiprocessing.freeze_support()
    uvicorn.run("hello:app", host="0.0.0.0", port=5555, reload=True)
pyinstaller --clean --noconfirm --onefile --hiddenimport hello run.py
>cd dist
>run.exe
←[32mINFO←[0m:     Will watch for changes in these directories: ['C:\\Users\\Rok\\Development\\pyi-uvicorn\\dist']
←[32mINFO←[0m:     Uvicorn …

Replies: 1 comment 6 replies

Comment options

You must be logged in to vote
6 replies
@krunaldodiya
Comment options

@krunaldodiya
Comment options

@rokm
Comment options

@rokm
Comment options

Answer selected by krunaldodiya
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants