Exemplo n.º 1
0
def create_app(object_name):
    """工厂函数"""
    app = Flask(__name__)
    app.config.from_object(object_name)
    recaptcha = ReCaptcha(app=app)

    db.init_app(app)
    bcrypt.init_app(app)
    recaptcha.init_app(app)

    @app.route('/')
    def index():
        return redirect(url_for('my_blog.home'))

    app.register_blueprint(blog.blog_buleprint)
    app.register_blueprint(main.main_blueprint)

    return app
Exemplo n.º 2
0
app = Flask(__name__)
app.config['MAIL_SERVER']='smtp.gmail.com'
app.config['MAIL_PORT'] = 465
app.config['SQLALCHEMY_DATABASE_URI']='postgresql://*****:*****@localhost/intuitionmachine'
app.config['MAIL_USERNAME'] = '******'
app.config['MAIL_PASSWORD'] = '******'
app.config['MAIL_USE_TLS'] = False
app.config['MAIL_USE_SSL'] = True
app.config['CSRF_ENABLED'] = True
app.config.update(dict( RECAPTCHA_ENABLED = True, RECAPTCHA_SITE_KEY = "6Lf3ti8UAAAAAHSO98fqkGKvDfP99T2VE_jfpwi7", RECAPTCHA_SECRET_KEY = "6Lf3ti8UAAAAAAv_LKpvRBez-FzAG7FWEIRvViV3" ))
app.config['SECRET_KEY']='Secret'
mail=Mail(app)
mail.init_app(app)
recaptcha= ReCaptcha()
recaptcha.init_app(app)
db=SQLAlchemy(app)

login_manager.init_app(app)
login_manager.login_message='You must be logged in to view this page.'


@login_manager.user_loader
def load_user(user_id):
	return User.query.get(int(user_id))

from flask_login import UserMixin
class User(UserMixin,db.Model):
	__tablename__ = 'users'
	id = db.Column(db.Integer,primary_key=True)
	fname = db.Column(db.String(50))
Exemplo n.º 3
0
from wtforms.validators import InputRequired
from flaskext.markdown import Markdown
from static.scripts.dbtools import submitImg, getImg, getImgR, getTopTags, db
from flask_recaptcha import ReCaptcha
import random

#Flask configs
application = Flask(__name__)
application.debug = True
application.secret_key = "1121Shoutai"
application.config[
    "RECAPTCHA_SITE_KEY"] = "6LfLVh0TAAAAAA5p4hjpcPcPoAZDtcP3SqG7d7Hv"
application.config[
    "RECAPTCHA_SECRET_KEY"] = "6LfLVh0TAAAAAGlTCKgi_WeuU1D-IOxOnkGO0gGA"
recaptcha = ReCaptcha()
recaptcha.init_app(application)

#Setup Markdown
Markdown(application)


#Submit Image form
class submitForm(Form):
    title = TextField(u'Title')
    url = TextField(u'Image URL',
                    [InputRequired("You must enter an image URL")])
    tags = TextField(u'Tags', [InputRequired("You must enter some tags")])
    nsfw = BooleanField(u'NSFW')
    submit = SubmitField(u'Submit')

Exemplo n.º 4
0
if not os.path.exists(config.LOG_TO):
    os.makedirs(config.LOG_TO)

if not os.path.exists(config.TMP_DIR):
    os.makedirs(config.TMP_DIR)

fh = logging.FileHandler(os.path.join(config.LOG_TO, config.LOGGER.file))
fh.setLevel(config.LOGGER.level)
fh.setFormatter(config.LOGGER.formatter)

pw_fh = logging.FileHandler(os.path.join(config.LOG_TO, config.LOGGER.peewee_file))
pw_fh.setLevel(config.LOGGER.level)
pw_fh.setFormatter(config.LOGGER.formatter)

peewee_log = Logger(pw_fh, "peewee")
log = Logger(fh, "My.trio")

log.info("Service started!")


recaptcha.init_app(app, GOOGLE_KEY, GOOGLE_SECRET_KEY)

from my_trio.accounts.views import register_page
from my_trio.accounts.errors import error_page
from my_trio.accounts import errors, views

app.register_blueprint(register_page)
app.register_blueprint(error_page)

Exemplo n.º 5
0
from rq import Queue
from rq.job import Job
from worker import conn
import uuid
from flask_mail import Mail
from flask_recaptcha import ReCaptcha
import config
import counter

app = Flask(__name__)
app.config.from_object('config')
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = True
app.config.update(dict(RECAPTCHA_ENABLED = True, RECAPTCHA_SITE_KEY = config.RECAPTCHA_SITE_KEY, RECAPTCHA_SECRET_KEY = config.RECAPTCHA_SECRET_KEY))
app.secret_key = "some_secret"
recaptcha = ReCaptcha()
recaptcha.init_app(app)
db = SQLAlchemy(app)
mail = Mail(app)

q = Queue(connection=conn)
ctr = counter.Counter()

import emails
from models import *

@app.route("/")
@app.route("/home")
def home():
	return render_template('home.html')

def save_info(organisation, email_address):