This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#... | |
class Config: | |
#... | |
CACHE_TYPE = 'simple' | |
#... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#... | |
from .extensions import db, cache | |
#... | |
def create_app(config_name): | |
#... | |
cache.init_app(app) | |
#... | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#... | |
from flask_caching import Cache | |
#... | |
cache = Cache() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#... | |
from .. import db | |
from ..models import Content | |
#... | |
@main.route('/link') | |
def get_link(): | |
#... | |
# Check if the URL contains www., and if not adds it |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#... | |
class Content(db.Model): | |
#... | |
@staticmethod | |
def from_json(json_content): | |
c = Content(title=json_content.get('title'), | |
url=json_content.get('url'), | |
description=json_content.get('description'), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#... | |
import ast | |
class Content(db.Model): | |
#... | |
def to_json(self, video=True, iframe=True, audio=True) | |
json_content = { | |
'id': self.id, | |
'title': self.title, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from . import db | |
from datetime import datetime | |
class Content(db.Model): | |
__tablename__ = 'content' | |
id = db.Column(db.Integer, primary_key=True) | |
timestamp = db.Column(db.DateTime, default=datetime.utcnow) | |
title = db.Column(db.Text, default=None) | |
date = db.Column(db.String, default=None) | |
description = db.Column(db.Text, default=None) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
from flask_migrate import Migrate | |
from app import create_app, db | |
app = create_app(os.getenv('FLASK_CONFIG') or 'default') | |
migrate = Migrate(app, db) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
basedir = os.path.abspath(os.path.dirname(__file__)) | |
class Config: | |
#... | |
SQLALCHEMY_TRACK_MODIFICATIONS = False | |
@staticmethod | |
def init_app(app): | |
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#... | |
from .extensions import db | |
def create_app(config_name): | |
#... | |
db.init_app(app) | |
#... |