| 
						
						
						
					 | 
					 | 
					@ -1,5 +1,4 @@
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					from apistar import Route
 | 
					 | 
					 | 
					 | 
					from apistar import Route, App
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					from apistar.http import HTMLResponse
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					from apistar_jwt import JWT
 | 
					 | 
					 | 
					 | 
					from apistar_jwt import JWT
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					from apistar_mail import MailComponent
 | 
					 | 
					 | 
					 | 
					from apistar_mail import MailComponent
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import logbook
 | 
					 | 
					 | 
					 | 
					import logbook
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -7,9 +6,9 @@ from sqlalchemy import create_engine
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					from pathlib import Path
 | 
					 | 
					 | 
					 | 
					from pathlib import Path
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					from cookie_api.auth import auth_routes
 | 
					 | 
					 | 
					 | 
					from cookie_api.auth import auth_routes
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					from cookie_api.logger import global_init
 | 
					 | 
					 | 
					 | 
					from cookie_api.logger import init_logging
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					from cookie_api.resources import cookie_routes
 | 
					 | 
					 | 
					 | 
					from cookie_api.resources import cookie_routes
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					from cookie_api.util import SQLAlchemyHook, SQLAlchemySession, MetaApp as App
 | 
					 | 
					 | 
					 | 
					from cookie_api.util import SQLAlchemyHook, SQLAlchemySession
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					BASEDIR = Path(__file__).parent
 | 
					 | 
					 | 
					 | 
					BASEDIR = Path(__file__).parent
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					TEMPLATE_DIR = BASEDIR.joinpath('templates')
 | 
					 | 
					 | 
					 | 
					TEMPLATE_DIR = BASEDIR.joinpath('templates')
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -17,18 +16,15 @@ STATIC_DIR = BASEDIR.joinpath('static')
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					logger = logbook.Logger(__name__)
 | 
					 | 
					 | 
					 | 
					logger = logbook.Logger(__name__)
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					engine = create_engine('postgresql://apistar@localhost:5432/apistar')
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					app_settings = {
 | 
					 | 
					 | 
					 | 
					app_settings = {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    "LOGGING": {
 | 
					 | 
					 | 
					 | 
					    "LOGGING": {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        "LEVEL": "DEBUG"
 | 
					 | 
					 | 
					 | 
					        "LEVEL": "INFO"
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    }
 | 
					 | 
					 | 
					 | 
					    }
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					}
 | 
					 | 
					 | 
					 | 
					}
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					def return_index_html():
 | 
					 | 
					 | 
					 | 
					def return_index_html(app: App):
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    with open(STATIC_DIR.joinpath('index.html'), mode='rb') as f:
 | 
					 | 
					 | 
					 | 
					    return app.render_template('index.html')
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        return HTMLResponse(content=f.read())
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					index = Route('/', 'GET', return_index_html)
 | 
					 | 
					 | 
					 | 
					index = Route('/', 'GET', return_index_html)
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -38,7 +34,7 @@ _routes = cookie_routes + auth_routes + [index]
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					_hooks = [SQLAlchemyHook]
 | 
					 | 
					 | 
					 | 
					_hooks = [SQLAlchemyHook]
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					_components = [
 | 
					 | 
					 | 
					 | 
					_components = [
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    SQLAlchemySession(engine=engine),
 | 
					 | 
					 | 
					 | 
					    SQLAlchemySession(engine=create_engine('postgresql://apistar@localhost:5432/apistar')),
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    JWT({
 | 
					 | 
					 | 
					 | 
					    JWT({
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        'JWT_USER_ID': 'sub',
 | 
					 | 
					 | 
					 | 
					        'JWT_USER_ID': 'sub',
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        'JWT_SECRET': 'thisisasecret',
 | 
					 | 
					 | 
					 | 
					        'JWT_SECRET': 'thisisasecret',
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -60,7 +56,8 @@ def application_factory(routes=_routes, components=_components, hooks=_hooks, se
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    """Returns an instance of Cookie API"""
 | 
					 | 
					 | 
					 | 
					    """Returns an instance of Cookie API"""
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    _settings = {**app_settings, **settings}
 | 
					 | 
					 | 
					 | 
					    _settings = {**app_settings, **settings}
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    global_init(_settings)
 | 
					 | 
					 | 
					 | 
					    init_logging(_settings)
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    logger.debug("Template directory {}".format(template_dir))
 | 
					 | 
					 | 
					 | 
					    logger.debug("Template directory {}".format(template_dir))
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    logger.debug("Static directory {}".format(STATIC_DIR))
 | 
					 | 
					 | 
					 | 
					    logger.debug("Static directory {}".format(STATIC_DIR))
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
					 | 
					
 
 |