Example #1
0
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(80), unique=True)
    email = db.Column(db.String(120), unique=True)

    def __repr__(self):
        return '<User %r>' % self.username
     
    def get_name(self):
        return self.username


app = Flask(__name__)
app.config["SECRET_KEY"] = "secret"  # for WTF-forms and login
app.config["BLOGGING_URL_PREFIX"] = "/blog"
app.config["BLOGGING_DISQUS_SITENAME"] = "test"
app.config["BLOGGING_SITEURL"] = "http://localhost:8000"
app.config["BLOGGING_SITENAME"] = "My Site"
app.config["FILEUPLOAD_IMG_FOLDER"] = "fileupload"
app.config["FILEUPLOAD_PREFIX"] = "/fileupload"
app.config["FILEUPLOAD_ALLOWED_EXTENSIONS"] = ["png", "jpg", "jpeg", "gif"]
app.config["SQLALCHEMY_DATABASE_URI"] = 'sqlite:////tmp/blog.db'
db.init_app(app)

with app.app_context():
    # extensions
    sql_storage = SQLAStorage(db=db)
    login_manager = LoginManager(app)
    db.create_all()
    # create test user if not exists
    user = User.query.filter_by(username="testuser").first()
    if user is None:
Example #2
0
reload(sys)
sys.setdefaultencoding('utf-8')

from flask import Flask, render_template_string, redirect,render_template
basedir = os.path.abspath(os.path.dirname(__file__))
from sqlalchemy import create_engine, MetaData
from flask.ext.login import UserMixin, LoginManager, \
    login_user, logout_user
from flask.ext.blogging import SQLAStorage, BloggingEngine

app = Flask(__name__)
app.config["SECRET_KEY"] = "secret"  # for WTF-forms and login
app.config["BLOGGING_URL_PREFIX"] = "/blog"
app.config["BLOGGING_SITENAME"] ="天天learning"
app.config["BLOGGING_SITEURL"] = "http://zhangliangchun.com"

# extensions
engine = create_engine('sqlite:///' + os.path.join(basedir, 'data.db'))
meta = MetaData()
sql_storage = SQLAStorage(engine, metadata=meta)
blog_engine = BloggingEngine(app, sql_storage)
login_manager = LoginManager(app)
meta.create_all(bind=engine)

# user class for providing authentication
class User(UserMixin):
    def __init__(self, user_id):
        self.id = user_id

    def get_name(self):
Example #3
0
from flask import Flask, render_template_string, redirect
from flask_login import UserMixin, LoginManager, login_user, logout_user
from flask_blogging import BloggingEngine
from flask_blogging.dynamodbstorage import DynamoDBStorage
from flask_fileupload.storage.s3storage import S3Storage
from flask_fileupload import FlaskFileUpload

app = Flask(__name__)
app.config["SECRET_KEY"] = "secret"  # for WTF-forms and login
app.config["BLOGGING_URL_PREFIX"] = "/blog"
app.config["BLOGGING_DISQUS_SITENAME"] = "test"
app.config["BLOGGING_SITEURL"] = ""
app.config["BLOGGING_SITENAME"] = "My Site"
app.config["BLOGGING_ALLOW_FILEUPLOAD"] = True
app.config["FILEUPLOAD_S3_BUCKET"]='quandldata'
app.config["FILEUPLOAD_PREFIX"] = "/upload"
app.config["FILEUPLOAD_ALLOWED_EXTENSIONS"] = ["png", "jpg", "jpeg", "gif"]


# extensions
s3storage = S3Storage(app)
file_upload = FlaskFileUpload(app, storage=s3storage)

dyn_storage = DynamoDBStorage(endpoint_url='http://localhost:8000')
blog_engine = BloggingEngine(app, dyn_storage, file_upload=file_upload)
login_manager = LoginManager(app)

class User(UserMixin):
    def __init__(self, user_id):
        self.id = user_id
Example #4
0
# coding=utf8
#


from flask import request
from flask import Flask, render_template_string, redirect
from sqlalchemy import create_engine, MetaData
from flask.ext.login import UserMixin, LoginManager, login_user, logout_user
from godai.sqlastorage import SQLAStorage
from godai.engine import BloggingEngine

app = Flask(__name__)
app.config["SECRET_KEY"] = "secret"  # for WTF-forms and login
app.config["BLOGGING_URL_PREFIX"] = "/blog"
app.config["BLOGGING_DISQUS_SITENAME"] = "test"
app.config["BLOGGING_SITEURL"] = "http://0.0.0.0:8000"
app.config["BLOGGING_SITENAME"] = u"加菲的博客"

# extensions
engine = create_engine('sqlite:////tmp/blog.db')
meta = MetaData()
sql_storage = SQLAStorage(engine, metadata=meta)
blog_engine = BloggingEngine(app, sql_storage)
login_manager = LoginManager(app)
meta.create_all(bind=engine)


class User(UserMixin):
    def __init__(self, user_id):
        self.id = user_id