File tree Expand file tree Collapse file tree 5 files changed +40
-0
lines changed Expand file tree Collapse file tree 5 files changed +40
-0
lines changed Original file line number Diff line number Diff line change 1+ from  fastapi  import  FastAPI 
2+ from  pydantic  import  BaseModel 
3+ app  =  FastAPI ()
4+ 
5+ 
6+ class  BookCreateModel (BaseModel ):
7+     title : str 
8+     author : str 
9+ 
10+ 
11+ @app .post ("/create_book" ) 
12+ async  def  create_book (book_data : BookCreateModel ):
13+     return  {
14+         "title" : book_data .title ,
15+         "author" : book_data .author 
16+     }
Original file line number Diff line number Diff line change 1+ from  fastapi  import  FastAPI 
2+ import  asyncio 
3+ 
4+ # creates an instance of the FastAPI class 
5+ app  =  FastAPI ()
6+ 
7+ 
8+ @app .get ("/" ) 
9+ async  def  read_root ():
10+     """ 
11+     await = pauses execution of this function until asyncio.sleep(2) 
12+     """ 
13+     await  asyncio .sleep (2 )
14+     return  {"message" : "Hello world" }
Original file line number Diff line number Diff line change 1+ fastapi [all ]
2+ pydantic [email ]
3+ slowapi 
4+ beautifulsoup4 
5+ requests 
6+ httpx 
7+ sqlalchemy 
8+ uvicorn 
9+ uvicorn [standard ]
10+ asyncio 
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments