File tree Expand file tree Collapse file tree 3 files changed +24
-6
lines changed Expand file tree Collapse file tree 3 files changed +24
-6
lines changed Original file line number Diff line number Diff line change 100100from  hrchatbot .prepdocslib .filestrategy  import  UploadUserFileStrategy 
101101from  hrchatbot .prepdocslib .listfilestrategy  import  File 
102102
103- bp  =  Blueprint ("routes" , __name__ , static_folder = "static" )
103+ bp  =  Blueprint ("routes" , __name__ , static_folder = "../ static" )
104104# Fix Windows registry issue with mimetypes 
105105mimetypes .add_type ("application/javascript" , ".js" )
106106mimetypes .add_type ("text/css" , ".css" )
@@ -126,7 +126,7 @@ async def favicon():
126126@bp .route ("/assets/<path:path>" ) 
127127async  def  assets (path ):
128128    return  await  send_from_directory (
129-         Path (__file__ ).resolve ().parent  /  "static"  /  "assets" , path 
129+         Path (__file__ ).resolve ().parent . parent  /  "static"  /  "assets" , path 
130130    )
131131
132132
Original file line number Diff line number Diff line change 1+ import  asyncio 
12import  os 
3+ import  socket 
24
35from  hrchatbot .app  import  create_app 
46from  hrchatbot .load_azd_env  import  load_azd_env 
57
6- # WEBSITE_HOSTNAME is always set by App Service, RUNNING_IN_PRODUCTION is set in main.bicep 
8+ 
9+ def  force_bind_port (desired_port = 8000 ):
10+     """Force bind to port using SO_REUSEADDR""" 
11+     with  socket .socket (socket .AF_INET , socket .SOCK_STREAM ) as  s :
12+         s .setsockopt (socket .SOL_SOCKET , socket .SO_REUSEADDR , 1 )
13+         try :
14+             s .bind (("localhost" , desired_port ))
15+             return  desired_port 
16+         except  OSError :
17+             # Still couldn't bind, find free port 
18+             s .bind (("localhost" , 0 ))
19+             return  s .getsockname ()[1 ]
20+ 
21+ 
722RUNNING_ON_AZURE  =  (
823    os .getenv ("WEBSITE_HOSTNAME" ) is  not None 
924    or  os .getenv ("RUNNING_IN_PRODUCTION" ) is  not None 
1328    load_azd_env ()
1429
1530app  =  create_app ()
31+ 
32+ if  __name__  ==  "__main__" :
33+     port  =  force_bind_port (8000 )
34+     url  =  f"http://localhost:{ port }  
35+     asyncio .run (app .run_task (host = "localhost" , port = port ))
Original file line number Diff line number Diff line change @@ -44,9 +44,7 @@ echo ""
4444
4545cd  ../backend
4646
47- port=50505
48- host=localhost
49- uv run quart --app hrchatbot.main:app run --port " $port " " $host " 
47+ uv run python -m hrchatbot.main
5048out=$? 
5149if  [ $out  -ne  0 ];  then 
5250    echo  " Failed to start backend" 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments