File tree Expand file tree Collapse file tree 9 files changed +67
-0
lines changed Expand file tree Collapse file tree 9 files changed +67
-0
lines changed Original file line number Diff line number Diff line change 1+ from  flask  import  Flask 
2+ from  config  import  config 
3+ 
4+ def  create_app (config_name ):
5+     app  =  Flask (__name__ )
6+     app .config .from_object (config [config_name ])
7+     config [config_name ].init_app (app )
8+     
9+     from  .main  import  main  as  main_blueprint 
10+     app .register_blueprint (main_blueprint )
11+     
12+     return  app 
Original file line number Diff line number Diff line change 1+ from  flask  import  Blueprint 
2+ 
3+ main  =  Blueprint ('main' , __name__ )
4+ 
5+ from  . import  views , errors 
Original file line number Diff line number Diff line change 1+ from  flask  import  render_template 
2+ from  . import  main 
3+ 
4+ @main .app_errorhandler (404 ) 
5+ def  page_not_found (e ):
6+     return  render_template ('404.html' ), 404 
7+     
8+ @main .app_errorhandler (500 ) 
9+ def  internal_server_error (e ):
10+     return  render_template ('500.html' ), 500 
Original file line number Diff line number Diff line change 1+ from  flask  import  render_template 
2+ from  . import  main 
3+ 
4+ 
5+ @main .route ('/' , methods = ['GET' ]) 
6+ def  index ():
7+     return  render_template ('index.html' )
Original file line number Diff line number Diff line change 1+ 404
Original file line number Diff line number Diff line change 1+ 500
Original file line number Diff line number Diff line change 1+ index
Original file line number Diff line number Diff line change 1+ import  os 
2+ basedir  =  os .path .abspath (os .path .dirname (__file__ ))
3+ 
4+ class  Config :
5+     SECRET_KEY  =  os .environ .get ('SECRET_KEY' ) or  'hard to guess string' 
6+     
7+     @staticmethod  
8+     def  init_app (app ):
9+         pass 
10+         
11+ class  DevelopmentConfig (Config ):
12+     DEBUG  =  True 
13+     
14+ class  TestingConfig (Config ):
15+     TESTING  =  True 
16+     
17+ class  ProductionConfig (Config ):
18+     pass 
19+     
20+ config  =  {
21+     'development' : DevelopmentConfig ,
22+     'testing' : TestingConfig ,
23+     'production' : ProductionConfig ,
24+     'default' : DevelopmentConfig 
25+ }
Original file line number Diff line number Diff line change 1+ import  os 
2+ from  app  import  create_app 
3+ 
4+ 
5+ app  =  create_app (os .getenv ('FLASK_CONFIG' ) or  'default' )
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments