3 ms·
#main.py from src.webserver import app import uvicorn if __name__ == '__main__': uvicorn.run( app, host='0.0.0.0',
by redsaber 3y ago
#main.py
from src.webserver import app
import uvicorn
if __name__ == '__main__':
uvicorn.run(
app,
host='0.0.0.0',
port=8080,
)
#webserver
from fastapi import FastAPI
app = FastAPI()
@app.get('/')
async def home():
return {
"home": True
}
@app.on_event("startup")
async def startup_event():
import webbrowser
ip_address = "http://localhost:8080/"
webbrowser.open(ip_address)
#create a python file for pyinstaller
import PyInstaller.__main__
if __name__ == '__main__':
name = "test"
pyinstaller_list = [
'main.py',
f'--name={name}',
'--clean',
'--onefile',
]
PyInstaller.__main__.run(pyinstaller_list)
I remember reading this part 'main:app' where you should import the app instead for pyinstaller.
- bheadmaster 3y agoYou are right. I think I've misremembered the module name - it was uwsgi, not uvicorn. This is a github issue where I discussed my original issue with PyInstaller devs - the dev explained the situation very well: https://github.com/pyinstaller/pyinstaller/issues/6362 https://github.com/pyinstaller/pyinstaller/issues/6362