Skip to content
site logo mobile

Forum in maintenance, we will back soon 🙂

FastAPI and UVICORN...
 
Notifications
Clear all

FastAPI and UVICORN server tip or trick

2 Posts
2 Users
1 Likes
619 Views
SSAdvisor
(@ssadvisor)
Posts: 804
Noble Member
Premium Member
Pythonista Prodigy Badge
Prompt Engineer
API Entrepreneur
Power Member
Points: 16007
Topic starter
 

I discovered, a trick that will make my life easier and I thought I'd share. Put this at the end of your main app file to automate the start of the server when you click the run button in your IDE.

from fastapi import FastAPI
...
app = FastAPI()
...

if __name__ == "__main__":
    import uvicorn
    uvicorn.run(app)

 

Regards,
Earnie Boyd, CEO
Seasoned Solutions Advisor LLC
Schedule 1-on-1 help
Join me on Slack

 
Posted : 05/31/2023 11:59 pm
Hasan Aboul Hasan
(@admin)
Posts: 873
Member Admin
Premium Member
Pythonista Prodigy Badge
Prompt Engineer
API Entrepreneur
Power Member
Points: 17598
 

Nice! thanks for sharing

 
Posted : 06/01/2023 7:39 am
Share: