Example #1
0
def test_send_email():
    mailForm= MailForm()
    if mailForm.validate_on_submit():#表单提交成功的判断
        try:
            app = Flask(__name__)
            app.config['SECRET_KEY'] = 'qiyeboy'
            #下面是SMTP服务器配置
            app.config['MAIL_SERVER'] = 'smtp.163.com' #电子邮件服务器的主机名或IP地址
            app.config['MAIL_PORT'] = '25' #电子邮件服务器的端口
            app.config['MAIL_USE_TLS'] = True #启用传输层安全
            app.config['MAIL_USERNAME'] ='13259744109@163.com' #os.environ.get('MAIL_USERNAME') #邮件账户用户名
            app.config['MAIL_PASSWORD'] = 'hywd1993'#os.environ.get('MAIL_PASSWORD') #邮件账户的密码

            mail = Mail(app)
            receiverName = mailForm.receiver.data #收件人文本框的内容
            styledata = mailForm.style.data#主题文本框的内容
            bodydata  = mailForm.body.data#正文文本框的内容
            msg = Message(styledata,sender='13259744109@163.com',recipients=[receiverName])#发件人,收件人
            msg.body = bodydata
            # send_email('2531145412@qq.com','Test email-function',)
            mail.send(msg)
            flash('邮件发送成功!')#提示信息
            return redirect(url_for('.index'))
        except:
            flash('邮件发送失败!')
            return redirect(url_for('.index'))
    return render_template('testemail.html',form=mailForm,name ='13259744109@163.com' )#渲染网页



# @main.route('/secret')
# @login_required
# def secret():
#     return 'Only authenticated users are allowed!'
Example #2
0
def create_app():
    app = Flask(__name__)
    app.config.from_object(Conf)
    print('create_app')
    # redis
    app.redis_store = redis.Redis(host=app.config["REDIS_HOST"], port=app.config["REDIS_PORT"], decode_responses=True)

    app.config['SQLALCHEMY_DATABASE_URI'] = Conf.MYSQL_INFO
    app.config['SQLALCHEMY_COMMIT_ON_TEARDOWN'] = True
    app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False

    # Mail
    app.config['MAIL_SERVER'] = Conf.MAIL_SERVER
    app.config['MAIL_PORT'] = Conf.MAIL_PORT
    app.config['MAIL_USE_TLS'] = Conf.MAIL_USE_TLS


    # 蓝图
    from app.admin import admin_api as admin_api_blueprint
    app.register_blueprint(admin_api_blueprint, url_prefix='/api/admin')

    from app.api.v1_0_0 import api_v1_0_0 as api_1_0_blueprint
    app.register_blueprint(api_1_0_blueprint, url_prefix='/api/v1.0.0')

    from app.api.v1_0_1 import api_v1_0_1 as api_1_1_blueprint
    app.register_blueprint(api_1_1_blueprint, url_prefix='/api/v1.0.1')

    # init
    db.init_app(app)
    return app
Example #3
0
	def create_app():

		global db, bootstrap, mail, login_manager, moment, pagedown
		app = Flask(__name__)

		from main import main as main_blueprint
		from auth import auth as auth_blueprint
		from admin import admin as admin_blueprint

		app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql://flask:gf37888676@172.17.0.25/flask'
		app.config['SQLAlCHEMY_COMMIT_ON_TEARDOWN'] = True
		app.config['FLASK_ADMIN'] = 'iamawar3player@163.com'
		app.config['FLASK_MAIL_SUBJECT_PREFIX'] = '[Flasky]'
		app.config['FLASK_MAIL_SENDER'] = 'Flasky Admin <iamawar3player@163.com>'
		app.config['MAIL_SERVER'] = 'smtp.163.com'
		app.config['MAIL_PORT'] = 25
		app.config['MAIL_USE_TLS'] = False
		app.config['MAIL_USERNAME'] = 'iamawar3player@163.com'
		app.config['MAIL_PASSWORD'] = 'fan86797121'
		app.config['DEBUG'] = True
		app.config['FLASKY_POSTS_PER_PAGE'] = 10
		app.config['SECRET_KEY'] = 'gf37888676'
		app.register_blueprint(main_blueprint)
		app.register_blueprint(auth_blueprint, url_prefix='/auth')
		app.register_blueprint(admin_blueprint, url_prefix='/admin')

		db = db.init_app(app)
		mail = mail.init_app(app)
		bootstrap = bootstrap.init_app(app)
		login_manager = login_manager.init_app(app)
		moment = moment.init_app(app)
		pagedown = pagedown.init_app(app)

		return app
Example #4
0
def create_app():
    app = Flask(__name__)
    app.config.update(
        CELERY_BROKER_URL='redis://localhost:6379/0',
        CELERY_RESULT_BACKEND='redis://localhost:6379/0'
    )
    app.config['MAIL_SERVER'] = 'smtp.gmail.com'
    app.config['MAIL_PORT'] = 587
    app.config['MAIL_USE_TLS'] = True
    app.config['MAIL_USERNAME'] = admin_imap
    app.config['MAIL_PASSWORD'] = admin_pass
    app.config['MAIL_DEFAULT_SENDER'] = 'server-error@example.com'

    return app
Example #5
0
from flask.ext.moment import Moment
from flask.ext.wtf import Form
from wtforms import StringField, SubmitField
from wtforms.validators import Required
from flask.ext.sqlalchemy import SQLAlchemy
from flask.ext.migrate import Migrate, MigrateCommand
from flask.ext.mail import Mail, Message

basedir = os.path.abspath(os.path.dirname(__file__))

app = Flask(__name__)
app.config['SECRET_KEY'] = 'hard to guess string'
app.config['SQLALCHEMY_DATABASE_URI'] =\
    'sqlite:///' + os.path.join(basedir, 'data.sqlite')
app.config['SQLALCHEMY_COMMIT_ON_TEARDOWN'] = True
app.config['MAIL_SERVER'] = 'smtp.googlemail.com'
app.config['MAIL_PORT'] = 587
app.config['MAIL_USE_TLS'] = True
app.config['MAIL_USERNAME'] = os.environ.get('MAIL_USERNAME')
app.config['MAIL_PASSWORD'] = os.environ.get('MAIL_PASSWORD')
app.config['FLASKY_MAIL_SUBJECT_PREFIX'] = '[Flasky]'
app.config['FLASKY_MAIL_SENDER'] = 'Flasky Admin <flasky@example.com>'
app.config['FLASKY_ADMIN'] = os.environ.get('FLASKY_ADMIN')

manager = Manager(app)
bootstrap = Bootstrap(app)
moment = Moment(app)
db = SQLAlchemy(app)
migrate = Migrate(app, db)
mail = Mail(app)
Example #6
0
app = Flask(__name__)

bootstrap = Bootstrap(app)
app.config['BOOTSTRAP_SERVE_LOCAL'] = True

dbpath = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'data.db')
app.config['SECRET_KEY'] = 'I will not tell'
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///{}'.format(dbpath)
app.config['SQLALCHEMY_COMMIT_ON_TEARDOWN'] = True
db = SQLAlchemy(app)

login_manager = LoginManager(app)
login_manager.login_view = 'login'

# XXX smtp.qq.com:587 failed with SSL.
app.config['MAIL_SERVER'] = 'smtp.qq.com'
app.config['MAIL_PORT'] = 587
app.config['MAIL_USE_TLS'] = True
app.config['MAIL_USERNAME'] = os.environ.get('MAIL_USERNAME')
app.config['MAIL_DEFAULT_SENDER'] = app.config['MAIL_USERNAME']
app.config['MAIL_PASSWORD'] = os.environ.get('MAIL_PASSWORD')
mail = Mail(app)

def send_email(to, subject, template=None, body=None, **kwargs):
    if not isinstance(to, list):
        to = [to]
    msg = Message(subject='[cstcmp] {}'.format(subject), recipients=to)
    if template:
        msg.body = render_template(template, **kwargs)
    elif body:
        msg.body = body
Example #7
0
    def build_user(self, data):
        user = super(GitHugAuth, self).build_user(data)
        user.avatar_url = data['user']['avatar_url']
        user.email = data['user'].get('email', '').strip() or None
        return user


#
# Setup
#
import requests

app = Flask(__name__)
app.secret_key = os.environ['SECRET']
app.config['MAIL_SERVER'] = os.environ.get('MAIL_SERVER', 'localhost')
app.config['MAIL_PORT'] = int(os.environ.get('MAIL_PORT', 25))
app.config['MAIL_USE_TLS'] = bool(os.environ.get('MAIL_USE_TLS', False))
app.config['MAIL_USE_SSL'] = bool(os.environ.get('MAIL_USE_SSL', False))
app.config['MAIL_USERNAME'] = os.environ.get('MAIL_USERNAME', None)
app.config['MAIL_PASSWORD'] = os.environ.get('MAIL_PASSWORD', None)
app.config['DEFAULT_MAIL_SENDER'] = 'hugs@githugs.org'
app.local = os.environ.get('LOCAL', None) is not None
app.debug = bool(app.local)
heroku = Heroku(app)
if app.config.get('SENTRY_DSN'):
    sentry = Sentry(app)
db = connect(
    app.config['MONGODB_DB'],
    host=app.config['MONGODB_HOST'],
    port=app.config['MONGODB_PORT'],
Example #8
0
from flask import Flask, render_template
from flask.ext.sqlalchemy import SQLAlchemy
from flask.ext.security import Security, SQLAlchemyUserDatastore, \
    UserMixin, RoleMixin, login_required
from flask_mail import Mail

# Create app
app = Flask(__name__)
app.config['DEBUG'] = True
app.config['SECRET_KEY'] = 'super-secret'
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite://'

# Flask Mail'
app.config['MAIL_SERVER'] = 'smtp.example.com'
app.config['MAIL_PORT'] = 465
app.config['MAIL_USE_SSL'] = True
app.config['MAIL_USERNAME'] = 'username'
app.config['MAIL_PASSWORD'] = 'password'
mail = Mail(app)

# Create database connection object
db = SQLAlchemy(app)

# Define models
roles_users = db.Table('roles_users',
        db.Column('user_id', db.Integer(), db.ForeignKey('user.id')),
        db.Column('role_id', db.Integer(), db.ForeignKey('role.id')))

class Role(db.Model, RoleMixin):
    id = db.Column(db.Integer(), primary_key=True)
    name = db.Column(db.String(80), unique=True)
Example #9
0
"""
The following section sets the overall configuration for flask-security
"""
app.config['SECURITY_PASSWORD_HASH'] = SECURITY_PASSWORD_HASH
app.config['SECURITY_PASSWORD_SALT'] = SECURITY_PASSWORD_SALT
app.config['SECURITY_CONFIRM_SALT'] = SECURITY_CONFIRM_SALT
app.config['SECURITY_RESET_SALT'] = SECURITY_RESET_SALT
app.config['SECURITY_CONFIRMABLE'] = True
app.config['SECURITY_RECOVERABLE'] = True
app.config['SECURITY_CHANGEABLE']  = SECURITY_CHANGEABLE


"""
The default settings for Mail
"""
app.config['MAIL_SERVER'] = MAIL_SERVER
app.config['MAIL_PORT'] = MAIL_PORT
app.config['MAIL_USE_TLS'] = MAIL_USE_TLS
app.config['MAIL_USERNAME'] = MAIL_USERNAME
app.config['MAIL_PASSWORD'] =MAIL_PASSWORD
app.config['MAIL_DEFAULT_SENDER'] = MAIL_DEFAULT_SENDER

appMail = Mail()
appMail.init_app(app)

# apply settings for default security views
app.config['SECURITY_LOGIN_URL']=SECURITY_LOGIN_URL
app.config['SECURITY_LOGOUT_URL']=SECURITY_LOGOUT_URL
app.config['SECURITY_REGISTER_URL']=SECURITY_REGISTER_URL
app.config['SECURITY_RESET_URL']=SECURITY_RESET_URL
app.config['SECURITY_CHANGE_URL']= SECURITY_CHANGE_URL
Example #10
0
####################### APP INIT & CONFIG ##############################
########################################################################
app = Flask(__name__)

manager = Manager(app)
mail = Mail(app)
login_manager.init_app(app)
bootstrap = Bootstrap(app)
app.config['SECRET_KEY'] = cfg.get("Secret", "wtf_secret_key")

# app.config['SERVER_NAME'] = "www.circl.lu:443"
# app.config['APPLICATION_ROOT'] = '/cve-portal'
# app.config['WTF_CSRF_ENABLED'] = True

# SMTP email config #
app.config['MAIL_SERVER'] = cfg.get('SMTP', 'server')
app.config['MAIL_PORT'] = cfg.get('SMTP', 'port')
app.config['MAIL_USE_TLS'] = cfg.get('SMTP', 'tls')
app.config['DEFAULT_MAIL_SENDER'] = cfg.get('SMTP', 'sender')

# Super Admin #
app.config['PORTAL_ADMIN'] = cfg.get('ADMIN', 'mail')

#  REDIS CONNECTION  #
r = redis.StrictRedis(host=cfg.get('REDIS', 'host'),
                      port=cfg.get('REDIS', 'port'),
                      db=cfg.get('REDIS', 'db'))

#  MONGO  #
app.config['MONGO_DBNAME'] = cfg.get('MONGO', 'dbname')
m = PyMongo(app)
Example #11
0
app = Flask(__name__)
BASE_ISP_URL = "http://149.171.37.237:5000/residence/isp/api/v1.0"

# Setting environment variables:
# export <CONFIG_VARIABLE_NAME>=<CONFIG_VARIABLE>

#Hash Key
app.config['SECRET_KEY'] = 'REMEMBER TO CHANGE THIS USE ENVIRONMENT VARS'

#SQLAlchemy
app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql+pymysql://root:openflow@localhost:3306/smp'
app.config['SQLALCHEMY_COMMIT_ON_TEARDOWN'] = True


#Email
app.config['MAIL_SERVER'] = 'michaelangelo.zuver.net.au'
app.config['MAIL_PORT'] = 465
app.config['MAIL_USE_SSL'] = True
app.config['MAIL_USERNAME'] = 'sdn@petertriho.com' #os.environ.get('MAIL_USERNAME')
app.config['MAIL_PASSWORD'] = 'sdnpass#2015' #os.environ.get('MAIL_PASSWORD')
app.config['MAIL_SUBJECT_PREFIX'] = '[reSiDeNce] '
app.config['MAIL_SENDER'] = 'reSiDeNce Admin <sdn@petertriho.com>'

#------------#
# Extensions #
#------------#
db = SQLAlchemy(app)
api = Api(app);
auth = HTTPBasicAuth()
mail = Mail(app)
Example #12
0
import uuid

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# tmpl_dir = os.path.join(BASE_DIR, 'templates')

webapp = Flask(__name__)

webapp.logger.addHandler(logging.StreamHandler(sys.stdout))
webapp.logger.setLevel(logging.ERROR)

webapp.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///' + os.path.join(BASE_DIR, 'db/app.db')
# webapp.config['SQLALCHEMY_DATABASE_URI'] = os.environ.get('DATABASE_URL', 'sqlite:////tmp/flask_app.db')
webapp.config['SECRET_KEY'] = 'foo'
webapp.config['WTF_CSRF_KEY'] = 'foo'

webapp.config['MAIL_SERVER'] = 'smtp.gmail.com'
webapp.config['MAIL_PORT'] = 465
webapp.config['MAIL_USE_TLS'] = False
webapp.config['MAIL_USE_SSL'] = True
webapp.config['MAIL_USERNAME'] = 'mahesh.thipparthi@gmail.com'
webapp.config['MAIL_PASSWORD'] = 'XXXXXX'
webapp.config['DEFAULT_MAIL_SENDER'] = 'mahesh.thipparthi@gmail.com'

db.init_app(webapp)

login_manager = LoginManager()
login_manager.init_app(webapp)

bcrypt = Bcrypt()

mail = Mail()
Example #13
0
from datetime import datetime, date
from collections import defaultdict
import random
import flask.ext.login as flask_login

# Security sensitive constants are imported from a file not being synced with github
from tpbeta_security import *

app = Flask(__name__)

app.secret_key = tpbeta_app_secret_key

app.config['SQLALCHEMY_DATABASE_URI'] = tpbeta_sqlalchemy_db_uri
app.config['SQLALCHEMY_POOL_RECYCLE'] = 280

app.config['MAIL_SERVER'] = tpbeta_mail_server
app.config['MAIL_PORT'] = tpbeta_mail_port
app.config['MAIL_USERNAME'] = tpbeta_mail_username
app.config['MAIL_PASSWORD'] = tpbeta_mail_password
app.config['MAIL_DEFAULT_SENDER'] = tpbeta_mail_default_sender
app.config['MAIL_USE_SSL'] = True

app.debug = True
db = SQLAlchemy(app)
mail = Mail(app)

login_manager = flask_login.LoginManager()
login_manager.init_app(app)
teachers = tpbeta_teacher_usernames

Example #14
0
from flask.ext.bootstrap import Bootstrap
from flask.ext.wtf import Form
from flask.ext.migrate import Migrate, MigrateCommand
from flask.ext.mail import Mail, Message
from wtforms import StringField, SubmitField
from wtforms.validators import Required
from flask.ext.sqlalchemy import SQLAlchemy
from threading import Thread

basedir = os.path.abspath(os.path.dirname(__file__))

app = Flask(__name__)
app.config['SECRET_KEY'] = 'hard to guess string'
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///' + os.path.join(basedir, 'data.sqlite')
app.config['SQLQLCHEMY_COMMIT_ON_TEARDOWN'] = True
app.config['MAIL_SERVER'] = 'stmp.google.com'
app.config['MAIL_PORT'] = 587
app.config['MAIL_USE_TLS'] = True
app.config['MAIL_USERNAME'] = os.environ.get('MAIL_USERNAME')
app.config['MAIL_PASSWORD'] = os.environ.get('MAIL_PASSWORD')
app.config['FLASKY_MAIL_SUBJECT_PREFIX'] = '[Flasky]'
app.config['FLASKY_MAIL_SENDER'] = 'Flasky Admin <flasky@example.com>'
app.config['FLASKY_ADMIN'] = os.environ.get('FLASKY_ADMIN')

manager = Manager(app)
bootstrap = Bootstrap(app)
db = SQLAlchemy(app)
migrate = Migrate(app, db)
manager.add_command('db', MigrateCommand)
mail = Mail(app)
Example #15
0
from flask_sqlalchemy import SQLAlchemy
from flask_script import Shell
from flask_migrate import Migrate, MigrateCommand
from flask_mail import Mail, Message
from threading import Thread


basedir = os.path.abspath(os.path.dirname(__file__))

app=Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI']=\
'sqlite:///' + os.path.join(basedir,'data.sqlite')
app.config['SQLALCHEMY_COMMIT_ON_TEARDOWN'] = True
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = True
app.config['SECRET_KEY'] = 'hello'
app.config['MAIL_SERVER'] = 'smtp.126.com'
app.config['MAIL_PORT'] = 25
app.config['MAIL_USE_TLS'] = True
app.config['MAIL_USERNAME'] = 'littleflasky@126.com'
app.config['MAIL_PASSWORD'] = 'miky123'
app.config['FLASKY_MAIL_SUBJECT_PREFIX'] = '[Flasky]'
app.config['FLASKY_MAIL_SENDER'] = 'littleflasky@126.com'
app.config['FLASKY_ADMIN'] = 'littleflasky@126.com'

mail=Mail(app)
db = SQLAlchemy(app)
manager = Manager(app)
bootstrap = Bootstrap(app)
moment = Moment(app)
migrate = Migrate(app, db)
manager.add_command("db", MigrateCommand)
Example #16
0
from flask import url_for
from flask import flash
from flask import copy_current_request_context

from flask_mail import Mail
from flask_mail import Message

import threading

import forms
import model

app = Flask(__name__)

##https://support.google.com/accounts/answer/6010255?hl=en
app.config['MAIL_SERVER'] = "smtp.gmail.com"
app.config['MAIL_PORT'] = 587
app.config['MAIL_USE_SSL'] = False
app.config['MAIL_USE_TLS'] = True
app.config['MAIL_USERNAME'] = "eduardo@codigofacilito.com"
app.config['MAIL_PASSWORD'] = "C=eQ9KF="


mail = Mail(app)

def send_email(user):
	msg = Message("Test numero uno",
							sender="eduardo@codigofacilito.com",
							recipients=["eduardo78d@gmail.com"])
	msg.html = render_template('thanks.html', user = user)
	mail.send(msg)
Example #17
0
from flask import Flask, request, session, g, redirect, url_for, abort, render_template, flash, jsonify, send_from_directory
from flask_cas import CAS
from flask_mail import Mail
from flask_mail import Message
import config

app = Flask(__name__)
# app.config.from_object('config')
app.config['CAS_SERVER'] = 'https://netid.rice.edu'
app.config['CAS_AFTER_LOGIN'] = 'afterlogin'
app.config['APP_URL'] = 'localhost:5000'
app.config.setdefault('CAS_USERNAME_SESSION_KEY', 'CAS_USERNAME')
CAS(app)

# Email setup
app.config['MAIL_SERVER'] = 'smtp.zoho.com'
app.config['MAIL_PORT'] = 465
app.config['MAIL_USERNAME'] = config.MAIL_USERNAME
app.config['MAIL_PASSWORD'] = config.MAIL_PASSWORD
app.config['MAIL_USE_TLS'] = False
app.config['MAIL_USE_SSL'] = True
app.config['MAIL_SUPPRESS_SEND'] = False
app.config['TESTING'] = False
mail = Mail(app)


def make_dicts(cursor, row):
    return dict((cursor.description[idx][0], value) for idx, value in enumerate(row))


con = lite.connect("wellbeing.db", check_same_thread=False)
Example #18
0
            app.config['CLOUD_SESSION_PROPERTIES']['project'],
        integrations=[FlaskIntegration()])
else:
    logging.info("No Sentry configuration")

# ----------  Init database package ----------
# Define the database object which is imported
# by modules and controllers
# --------------------------------------------
app.config['SQLALCHEMY_DATABASE_URI'] = app.config['CLOUD_SESSION_PROPERTIES']['database.url']
logging.debug("Initializing database connection: %s", app.config['SQLALCHEMY_DATABASE_URI'])

db = SQLAlchemy(app)


app.config['MAIL_SERVER'] = app.config['CLOUD_SESSION_PROPERTIES']['mail.host']
logging.debug("Configuring SMTP properties for %s", app.config['MAIL_SERVER'])

# Set the correct server port for encrypted vs unencrypted communications
if app.config['CLOUD_SESSION_PROPERTIES']['mail.port'] is None:
    if app.config['CLOUD_SESSION_PROPERTIES']['mail.tls']:
        app.config['MAIL_PORT'] = 587
    else:
        app.config['MAIL_PORT'] = 25

    logging.info("Email server default port set to port %s", app.config['MAIL_PORT'])
else:
    app.config['MAIL_PORT'] = app.config['CLOUD_SESSION_PROPERTIES']['mail.port']

app.config['MAIL_USE_TLS'] = app.config['CLOUD_SESSION_PROPERTIES']['mail.tls']
app.config['MAIL_USE_SSL'] = app.config['CLOUD_SESSION_PROPERTIES']['mail.ssl']
Example #19
0
mail = Mail()
pagedown = PageDown()

moment = Moment()

if __name__ == '__main__':
    bootstrap = Bootstrap()


    app = Flask(__name__)
    app.config['SECRET_KEY'] = 'hard to guess string'
    app.config['SQLALCHEMY_DATABASE_URI'] =\
        'mysql://root:mopon@172.16.34.7:3306/test'
    app.config['SQLALCHEMY_COMMIT_ON_TEARDOWN'] = True

    app.config['MAIL_SERVER'] = 'smtp.qiye.163.com'
    app.config['MAIL_PORT'] = 25
    app.config['MAIL_USE_TLS'] = False
    app.config['MAIL_USERNAME'] = 'chenxiaolu.sz@mopon.cn'
    app.config['MAIL_PASSWORD'] = 'cxl@taijiu2015'
    app.config['FLASKY_MAIL_SUBJECT_PREFIX'] = '[Flasky]'
    app.config['FLASKY_MAIL_SENDER'] = 'Flasky Admin <chenxiaolu.sz@mopon.cn>'
    app.config['FLASKY_ADMIN'] = 'chenxiaolu.sz@mopon.cn'
    app.config['FLASKY_POSTS_PER_PAGE'] = 2
    app.config['FLASKY_FOLLOWERS_PER_PAGE'] = 2
    app.config['FLASKY_COMMENTS_PER_PAGE'] = 2

    bootstrap.init_app(app)
    moment.init_app(app)
    db.init_app(app)
    login_manager.init_app(app)
Example #20
0
File: app.py Project: sznote/flask
from flask_mail import Mail


app = Flask(__name__)



basedir = os.path.abspath(os.path.dirname(__file__))

app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = True
app.config["SQLALCHEMY_DATABASE_URI"] = 'sqlite:///' + os.path.join(basedir, 'app.db')
app.config['SECURITY_REGISTERABLE'] = True
app.config['SECRET_KEY'] = 'super-secret'

app.config['MAIL_SERVER']='172.16.100.10'
app.config['MAIL_PORT'] = '25'
#SQLALCHEMY_TRACK_MODIFICATIONS =  True

mail = Mail()
mail.init_app(app)


db = SQLAlchemy(app)


# Define models

roles_users = db.Table('roles_users',
        db.Column('user_id', db.Integer(), db.ForeignKey('user.id')),
        db.Column('role_id', db.Integer(), db.ForeignKey('role.id')))
Example #21
0
COUPON_ENDPOINT = 'coupon'

# services
SERVICE_POD = "pod"
SERVICE_TLP = "tlp"
SERVICES = [SERVICE_POD, SERVICE_TLP]

# models
MODELS_POD_OCR = "ocr"
MODELS_POD_BAYES_SPAM = "bayes_spam"
MODELS_POD_FACE_DETECT = "face_detect"
MODELS = [MODELS_POD_OCR, MODELS_POD_BAYES_SPAM, MODELS_POD_FACE_DETECT]


# mail settings
PRAXYK_API_APP.config['MAIL_SERVER']   = 'smtp.googlemail.com'
PRAXYK_API_APP.config['MAIL_PORT']     = 587
PRAXYK_API_APP.config['MAIL_USE_TLS']  = True
PRAXYK_API_APP.config['MAIL_USE_SSL']  = False
# gmail authentication
PRAXYK_API_APP.config['MAIL_USERNAME'] = apiconf['email']
PRAXYK_API_APP.config['MAIL_PASSWORD'] = apiconf['emailpassword']

mail = Mail(PRAXYK_API_APP)

# mail accounts
PRAXYK_API_APP.config['MAIL_DEFAULT_SENDER'] = 'from@example.com'

# default access token expiration time (24 hours)
TOKEN_EXPIRATION = apiconf['token_expiration']
Example #22
0
	return '.' in filename and \
		filename.rsplit('.',1)[1] in ALLOWED_EXTENSIONS

def allowed_file_notes(filename):
	print "checking allowed"
	return '.' in filename and \
		filename.rsplit('.',1)[1] in ALLOWED_EXTENSIONS_NOTES

def allowed_img_file(filename):
	return '.' in filename and \
		filename.rsplit('.',1)[1] in ALLOWED_EXTENSIONS_PICS
########## end File Upload Setup ##########

########## Mail Setup ##########
mail = Mail()
app.config['MAIL_SERVER'] = 'mail.mrscutrona.com'
app.config['MAIL_PORT'] = 465
app.config['MAIL_USE_SSL'] = True
app.config['MAIL_USERNAME'] = 'bugs@mrscutrona.com'
app.config['MAIL_PASSWORD'] = config.epw
mail.init_app(app)
########## end Mail Setup ##########

########## Pagination Setup ##########
PER_PAGE = 5
def url_for_other_page(page):
	args = dict(request.view_args.items() + request.args.to_dict().items())
	args['page'] = page
	return url_for(request.endpoint, **args)
app.jinja_env.globals['url_for_other_page'] = url_for_other_page
########## end Pagination Setup ##########
Example #23
0
from functools import wraps
from flask.ext.mail import Mail
from flask.ext.mail import Message


config = configparser.ConfigParser()
config.readfp(codecs.open("../config/config.ini", "r", "utf-8"))

app = Flask(__name__)

app.config['HEADERS'] = {'Referer': 'http://music.163.com'}
app.config['OFFSET'] = 0
app.config['LIMIT'] = 100
app.config['JSON_AS_ASCII'] = False

app.config['MAIL_SERVER'] = config['MAIL']['SERVER']
app.config['MAIL_PORT'] = int(config['MAIL']['PORT'])
app.config['MAIL_USE_SSL'] = True
app.config['MAIL_USERNAME'] = config['MAIL']['USERNAME']
app.config['MAIL_PASSWORD'] = config['MAIL']['PASSWORD']

mail = Mail(app)


"""
API website template related
"""

@app.route('/', methods=['GET'])
def host():
	return redirect('/v1')
Example #24
0
ENCRYPTION_KEY = SettingsUtil.EncryptionKey.get(RUN_MODE == 'development')

app = Flask(__name__)

app.secret_key = CryptoUtil.decrypt(config.ENCRYPTED_SESSION_KEY,ENCRYPTION_KEY)

app.config['STRIPE_TOKEN'] = CryptoUtil.decrypt(config.ENCRYPTED_STRIPE_TOKEN, ENCRYPTION_KEY)
app.config['DATABASE_PASSWORD'] = CryptoUtil.decrypt(config.ENCRYPTED_DATABASE_PASSWORD, ENCRYPTION_KEY)
app.config['STRIPE_CACHE_REFRESH_MINUTES'] = config.STRIPE_CACHE_REFRESH_MINUTES
app.config['STRIPE_CACHE_REBUILD_MINUTES'] = config.STRIPE_CACHE_REBUILD_MINUTES
app.config['STRIPE_CACHE_REFRESH_BACKREACH_MIN'] = config.STRIPE_CACHE_REFRESH_BACKREACH_MIN
app.config['ACCESS_CONTROL_HOSTNAME'] = config.ACCESS_CONTROL_HOSTNAME
app.config['ACCESS_CONTROL_SSH_PORT'] = config.ACCESS_CONTROL_SSH_PORT

app.config['MAIL_SERVER'] = config.MAIL_SERVER
app.config['MAIL_PORT'] = config.MAIL_PORT
app.config['MAIL_USE_TLS'] = config.MAIL_USE_TLS
app.config['MAIL_USE_SSL'] = config.MAIL_USE_SSL
app.config['MAIL_USERNAME'] = CryptoUtil.decrypt(config.ENCRYPTED_MAIL_USERNAME,ENCRYPTION_KEY)
app.config['MAIL_PASSWORD'] = CryptoUtil.decrypt(config.ENCRYPTED_MAIL_PASSWORD,ENCRYPTION_KEY)
app.config['ADMIN_PASSPHRASE'] = CryptoUtil.decrypt(config.ENCRYPTED_ADMIN_PASSPHRASE,ENCRYPTION_KEY)
app.config['LOG_FILE'] = config.LOG_FILE

# Logging
file_handler = logging.FileHandler(app.config['LOG_FILE'])
file_handler.setFormatter(logging.Formatter('%(asctime)s - %(levelname)s: %(message)s'))
file_handler.setLevel(logging.INFO)
app.logger.setLevel(logging.INFO)
app.logger.addHandler(file_handler)
Example #25
0
        os.environ["OPENSHIFT_POSTGRESQL_DB_URL"],
        os.environ["OPENSHIFT_APP_NAME"])
else:
    database_url = os.environ["DATABASE_URL"]

app.config['SQLALCHEMY_DATABASE_URI'] = database_url
app.config['GCLIENT_ID'] = os.environ['GCLIENT_ID']
app.config['GCLIENT_SECRET'] = os.environ['GCLIENT_SECRET']
app.config['DATE_FORMAT'] = '%Y-%m-%d'
app.config['PAGE_SIZE'] = os.environ.get('PAGE_SIZE', '20')
app.config['URL_ROOT'] = os.environ['URL_ROOT']
app.config['HASH_KEY'] = os.environ['HASH_KEY']

# Mail setup
app.config['EMAIL_FROM'] = os.environ.get("EMAIL_FROM", "portal@example.com")
app.config['MAIL_SERVER'] = os.environ.get("MAIL_SERVER", "smtp.gmail.com")
app.config['MAIL_SERVER_IMAP'] = os.environ.get(
    "MAIL_SERVER_IMAP", "imap.gmail.com")
app.config['MAIL_PORT'] = os.environ.get("MAIL_PORT", 25)
app.config['MAIL_PORT_IMAP'] = os.environ.get("MAIL_PORT_IMAP", 993)
app.config['MAIL_USERNAME'] = os.environ.get("MAIL_USERNAME")
app.config['MAIL_PASSWORD'] = os.environ.get("MAIL_PASSWORD")
if os.environ.get("MAIL_USE_TLS") == "True":
    app.config['MAIL_USE_TLS'] = True
if os.environ.get("MAIL_USE_SSL") == "True":
    app.config['MAIL_USE_SSL'] = True

app.config['FILESTORE_URL'] = os.environ.get("FILESTORE_URL")
app.config['FILESTORE_SITE'] = os.environ.get("FILESTORE_SITE")
app.config['FILESTORE_USER'] = os.environ.get("FILESTORE_USER")
app.config['FILESTORE_PASSWORD'] = os.environ.get("FILESTORE_PASSWORD")
Example #26
0
from flask.ext.mail import Message, Mail
from forms import ContactForm
from wsgi import ReverseProxied
from ConfigParser import RawConfigParser
import os
import re

CONFIG_ENV = 'CONTACT_POTION_CONFIG'

config_filename = os.getenv(CONFIG_ENV, 'sample.config')
config = RawConfigParser()
config.read(config_filename)

app = Flask(__name__)
app.secret_key = config.get('GLOBAL', 'secret_key')
app.config['MAIL_SERVER'] = config.get('GLOBAL', 'mailserver')
app.config['MAIL_PORT'] = config.getint('GLOBAL', 'mailport')
app.config['MAIL_USE_SSL'] = config.getboolean('GLOBAL', 'mailusessl')
app.config['MAIL_USERNAME'] = config.getint('GLOBAL', 'username')
app.config['MAIL_PASSWORD'] = config.getboolean('GLOBAL', 'password')

mail = Mail()
mail.init_app(app)

app.wsgi_app = ReverseProxied(app.wsgi_app)

@app.route('/', methods=['GET', 'POST'])
def contact():
    request_config = get_request_config()
    form = ContactForm()
    form.category.choices = ((choice, choice)
Example #27
0
        if is_lazy_string(o):
            return str(o)

        return BaseEncoder.default(self, o)

app.json_encoder = JSONEncoder

app.config['BABEL_DEFAULT_LOCALE'] = 'ru'
babel = Babel(app)


@babel.localeselector
def get_locale():
    return 'ru'

app.config['MAIL_SERVER'] = dotenv.get(
    'KNOTMARKER_MAIL_SERVER', 'smtp.gmail.com')
app.config['MAIL_PORT'] = 465
app.config['MAIL_USE_SSL'] = True
app.config['MAIL_USERNAME'] = dotenv.get(
    'KNOTMARKER_MAIL_USERNAME', 'knotmarker@gmail.com')
app.config['MAIL_PASSWORD'] = dotenv.get('KNOTMARKER_MAIL_PASSWORD')

mail = Mail(app)

app.config['MONGODB_DB'] = dotenv.get('KNOTMARKER_MONGODB_DB', 'knotmarker')
app.config['MONGODB_HOST'] = dotenv.get('KNOTMARKER_MONGODB_HOST', 'localhost')
app.config['MONGODB_PORT'] = dotenv.get('KNOTMARKER_MONGODB_PORT', 27017)
app.config["SECRET_KEY"] = bytes(dotenv.get('KNOTMARKER_SECRET_KEY'), 'utf8')
app.config["SECURITY_REGISTERABLE"] = True
app.config["SECURITY_CONFIRMABLE"] = True
app.config["SECURITY_RECOVERABLE"] = True
#xxxxx
app.config['SQLALCHEMY_DATABASE_URI'] = 'postgresql://postgres:xxxxxxxx@localhost/flask_example'

# Set config values for Flask-Security.
# We're using PBKDF2 with salt.
app.config['SECURITY_PASSWORD_HASH'] = 'pbkdf2_sha512'
# Replace this with your own salt.
app.config['SECURITY_PASSWORD_SALT'] = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'

# Flask-Security optionally sends email notification to users upon registration, password reset, etc.
# It uses Flask-Mail behind the scenes.
# Set mail-related config values.
# Replace this with your own "from" address
app.config['SECURITY_EMAIL_SENDER'] = 'no-reply@example.com'
# Replace the next five lines with your own SMTP server settings
app.config['MAIL_SERVER'] = 'email-smtp.us-west-2.amazonaws.com'
app.config['MAIL_PORT'] = 465
app.config['MAIL_USE_SSL'] = True
app.config['MAIL_USERNAME'] = 'xxxxxxxxxxxxxxxxxxxx'
app.config['MAIL_PASSWORD'] = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'

# Initialize Flask-Mail and SQLAlchemy
mail = Mail(app)
db = SQLAlchemy(app)

# Create a table to support a many-to-many relationship between Users and Roles
roles_users = db.Table(
    'roles_users',
    db.Column('user_id', db.Integer(), db.ForeignKey('user.id')),
    db.Column('role_id', db.Integer(), db.ForeignKey('role.id'))
)
Example #29
0
except:
    print "*** Running without DB ***"
    rdb = None

app = Flask(__name__, static_url_path='')
app.debug = True
#app.debug = False
app.config['SECRET_KEY'] = 'secret!'
app.config['DEBUG'] = True
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///wv.db'

app.config['SECURITY_TRACKABLE'] = True
app.config['SECURITY_REGISTERABLE'] = True
app.config['SECURITY_EMAIL_SENDER'] = 'no-reply@pollywss.paldeploy.com'

app.config['MAIL_SERVER'] = '192.168.20.18'
app.config['MAIL_PORT'] = 25
#app.config['MAIL_USE_SSL'] = True
app.config['MAIL_USE_SSL'] = False
app.config['MAIL_USERNAME'] = 'flycam'
app.config['MAIL_PASSWORD'] = 'flyspec'
mail = Mail(app)

socketio = SocketIO(app)

# Create database connection object
db = SQLAlchemy(app)

# Define models
roles_users = db.Table('roles_users',
        db.Column('user_id', db.Integer(), db.ForeignKey('user.id')),
Example #30
0
# encoding:utf-8
from flask import Flask,render_template,session,redirect,url_for,flash,request
from flask.ext.bootstrap import Bootstrap
from flask.ext.moment import Moment
from datetime import datetime
from flask.ext.wtf import Form
from wtforms import SubmitField,StringField
from wtforms.validators import required
from flask.ext.sqlalchemy import SQLAlchemy
from flask.ext.mail import Mail
from flask.ext.mail import Message
from threading import Thread
import RealIP
import dbconfig

import sys
reload(sys)
sys.setdefaultencoding('utf-8')
#初始化Flask 实例,添加秘钥,数据库参数配置,邮箱配置
app = Flask(__name__)
app.config['SECRET_KEY'] = 'hard to guess string'
app.config['SQLALCHEMY_DATABASE_URI'] = dbconfig.SQLALCHEMY_DATABASE_URI
app.config['SQLALCHEMY_COMMIT_ON_TEARDOWN'] = dbconfig.SQLALCHEMY_COMMIT_ON_TEARDOWN
app.config['MAIL_SERVER'] = 'smtp.139.com'
app.config['MAIL_PORT'] = 25
app.config['MAIL_USE_TLS'] = True
app.config['MAIL_USERNAME'] = '18898761417@139.com'
app.config['MAIL_PASSWORD'] = '***************'
app.config['FLASKY_MAIL_SUBJECT_PREFIX'] = '[Flasky]'
app.config['FLASKY_MAIL_SENDER'] = 'Flasky Admin <18898761417@139.com>'