You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							16 lines
						
					
					
						
							585 B
						
					
					
				
			
		
		
	
	
							16 lines
						
					
					
						
							585 B
						
					
					
				| from datetime import datetime | |
| from app import app, db | |
|  | |
| class Url(db.Model): | |
|     id = db.Column(db.Integer, primary_key=True) | |
|     url = db.Column(db.String(2000), nullable=False) | |
|     hash = db.Column(db.String(20), index=True, unique=True, nullable=False) | |
|     birth = db.Column(db.DateTime, default=datetime.utcnow) | |
|     death = db.Column(db.DateTime) | |
|     view_counter = db.Column(db.Integer) | |
|  | |
|     def __init__(self, **kwargs): | |
|         super(Url, self).__init__(**kwargs) | |
|  | |
|         if not self.url.lower().startswith(('http://', 'https://')): | |
|             self.url = f'https://{self.url}'
 | |
| 
 |