Example #1
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 #2
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 #3
0
# Define the database object which is imported
# by modules and controllers
db = SQLAlchemy(app)

# Initiate Bower
Bower(app)

# Sample HTTP error handling
@app.errorhandler(404)
def not_found(error):
    return render_template("404.html"), 404


# Import a module / component using its blueprint handler variable (mod_auth)

app.config["MAIL_SERVER"] = "evop5.areserver.net"
app.config["MAIL_PORT"] = 465
app.config["MAIL_USE_SSL"] = True
app.config["MAIL_USERNAME"] = "pruebas.cms@asacoop.com"
app.config["MAIL_PASSWORD"] = "admin1234"
mail = Mail(app)

# RESTful
api = Api(app)

# Import a module / component using its blueprint handler variable (mod_auth)
from app.authentication.controllers import mod_auth as auth_module

# from app.sections.controllers import mod_sec as sec_module
from app.sections.controllers import api_db as sec_module
Example #4
0
from wtforms.validators import Required, data_required

from flask.ext.sqlalchemy import SQLAlchemy
from flask.ext.migrate import Migrate, MigrateCommand
from flask.ext.mail import Mail

basedir = os.path.abspath(os.path.dirname(__file__))
app = Flask(__name__)
app.config["SECRET_KEY"] = "aaaa"
app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///" + os.path.join(basedir, "data.sqlite")
app.config["SQLALCHEMY_COMMIT_ON_TEARDOWN"] = True

app.config["FLASKY_MAIL_SUBJECT_PREFIX"] = "[Flasky]"
app.config["FLASKY_MAIL_SENDER"] = "<moustachedtom@gmail.com>"

app.config["MAIL_SERVER"] = "smtp.googlemail.com"
app.config["MAIL_PORT"] = 587
app.config["MAIL_USE_TLS"] = True
app.config["MAIL_USER_NAME"] = os.environ.get("MAIL_USERNAME")
app.config["MAIL_PASSWORD"] = os.environ.get("MAIL_PASSWORD")


db = SQLAlchemy(app)
manager = Manager(app)
bootstrap = Bootstrap(app)
moment = Moment(app)
migrate = Migrate(app, db)
mail = Mail(app)


class Role(db.Model):
Example #5
0
    __delattr__ = dict.__delitem__


# Instanciate config
config = Config()

# Instanciate FLASK
app = Flask(__name__)

# Flask settings
app.config["SESSION_TYPE"] = "memcached"
app.config["SECRET_KEY"] = config.secret_key
app.config["TAP"] = config

# Setup Mail
app.config["MAIL_SERVER"] = config.mail_host.split(":")[0]
app.config["MAIL_PORT"] = int(config.mail_host.split(":")[1])
app.config["MAIL_USERNAME"] = config.mail_user
app.config["MAIL_PASSWORD"] = config.mail_pass
app.config["MAIL_DEFAULT_SENDER"] = config.mail_from
app.config["MAIL_USE_TLS"] = True
app.config["MAIL_USE_SSL"] = False
mail = Mail(app)

# Setup Storage
app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///database.db"
app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
db = SQLAlchemy(app)

# Setup CORS
cors = CORS(app, resources={r".*/api/v1/.*": {"origins": "*"}})
Example #6
0
from flask.ext.security import Security, UserMixin, RoleMixin, login_required
from flask.ext.security.datastore.sqlalchemy import SQLAlchemyUserDatastore
from concert1.security import security
from concert1.base import base

# FLASK_APP_DIR = os.path.dirname(os.path.abspath(__file__))

# Create app
app = Flask(__name__)

# Config requires legit Gmail username and password
# Move eventually to config.py w/ diff config for production
app.config["DEBUG"] = True
app.config["SECRET_KEY"] = "super-secret"
app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///test.db"
app.config["MAIL_SERVER"] = "smtp.example.com"
app.config["MAIL_PORT"] = 465
app.config["MAIL_USE_SSL"] = True
app.config["MAIL_USERNAME"] = "sean@concerttalent.com"
app.config["MAIL_PASSWORD"] = "password"
app.config["DEFAULT_MAIL_SENDER"] = "Admin < sean@concerttalent.com >"
# 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')))
Example #7
0
# MongoDB Config
app.config["MONGODB_DB"] = mongo_db
app.config["MONGODB_HOST"] = mongo_host
app.config["MONGODB_PORT"] = mongo_port

# Security Features
app.config["SECURITY_REGISTERABLE"] = user_enable_registration
app.config["SECURITY_TRACKABLE"] = user_enable_tracking
app.config["SECURITY_EMAIL_SENDER"] = user_from_email
app.config["SECURITY_PASSWORD_HASH"] = pwhash
app.config["SECURITY_PASSWORD_SALT"] = salt
app.config["SECURITY_CONFIRMABLE"] = True
app.config["SECURITY_EMAIL_SUBJECT_REGISTER"] = user_register_email_subject

# Email
app.config["MAIL_SERVER"] = mail_url
app.config["DEBUG"] = False
app.config["MAIL_PORT"] = mail_port
app.config["MAIL_USE_SSL"] = mail_SSL
app.config["MAIL_USE_TLS"] = mail_TLS
app.config["MAIL_USERNAME"] = mail_user
app.config["MAIL_PASSWORD"] = mail_pass
app.config["MAIL_SUPPRESS_SEND"] = False


# Create database connection object
db = MongoEngine(app)
# Bootstrap
Bootstrap(app)
# Setup Mail
mail = Mail(app)
Example #8
0

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)
from form_templates import *

# Import logging module to allow information logging to a file.
import logging

# Import mail modules for email notification support.
from flask.ext.mail import Mail, Message

# Anytime we run an app in Python a special variable called __name__ is defined.
#
app = Flask(__name__)

# Setup mail server configuration and mail instance for email support.
# MAIL_USERNAME and MAIL_PASSWORD must be setup prior to initiation.
# This can be done in the vagrant console using $ export MAIL_USERNAME 'xxxx'
app.config["MAIL_SERVER"] = "smtp.live.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["DEFAULT_MAIL_SUBJECT"] = "[The Puppy Haven]"
app.config["DEFAULT_MAIL_SENDER"] = "Admin <Ben-fraser@hotmail.co.uk>"
app.config["SECRET_KEY"] = "hellomotto"
app.config["DEFAULT_ADMIN"] = "Admin <Ben-fraser@hotmail.co.uk>"

mail = Mail(app)

engine = create_engine("sqlite:///puppyshelter.db")
# Bind the engine to the metadata of the Base class so that the
# declaratives can be accessed through a DBSession instance
Base.metadata.bind = engine
Example #10
0
    POOL.put(conn)
    return


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',
Example #11
0
from flask import Flask
from flask.ext.sqlalchemy import SQLAlchemy
from flask_mail import Mail
from forms import LoginForm
from config import *


app = Flask(__name__)
app.config.from_object("config")

app.config["MAIL_SERVER"] = "192.168.1.223"
app.config["MAIL_PORT"] = "25"
app.config["MAIL_USERNAME"] = "s_int7"
app.config["MAIL_PASSWORD"] = "1234"
app.config["MAIL_USE_TLS"] = False
app.config["MAIL_USE_SSL"] = False
app.config["MAIL_DEBUG"] = True
app.config["DEFAULT_MAIL_SENDER"] = True

mail = Mail(app)
db = SQLAlchemy(app)

from app import views, models
Example #12
0
File: app.py Project: Fize/cvpn
manager = Manager(app)
db = SQLAlchemy(app)
migrate = Migrate(app, db)


def parser(field, key):
    a = Parser(os.path.join(basedir, "config.ini"))
    return a.get(field, key)


# config
app.config["SECRET_KEY"] = parser("secret", "key")
app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite://" + parser("cvpn", "data_path")
app.config["SQLALCHEMY_COMMIT_ON_TEARDOWN"] = True
app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = True
app.config["MAIL_SERVER"] = parser("mail", "smtp_server")
app.config["MAIL_PORT"] = int(parser("mail", "smtp_port"))
app.config["MAIL_USE_TLS"] = parser("mail", "mail_tls")
app.config["MAIL_USE_SSL"] = parser("mail", "mail_ssl")
app.config["MAIL_USERNAME"] = parser("mail", "mail_user")
app.config["MAIL_PASSWORD"] = parser("mail", "mail_password")
app.config["FLASK_MAIL_SUBJECT_PREFIX"] = parser("mail", "prefix")
app.config["FLASK_MAIL_SENDER"] = "cvpn admin<%s>" % app.config["MAIL_USERNAME"]


mail = Mail(app)


def send_email(to, subject, template, **kwargs):
    msg = Message(
        app.config["FLASK_MAIL_SUBJECT_PREFIX"] + subject, sender=app.config["FLASK_MAIL_SENDER"], recipients=[to]
Example #13
0
from flask_mail import Mail, Message
from flask_sqlalchemy import SQLAlchemy
from wtforms import StringField, SubmitField
from wtforms.validators import Required


app = Flask(__name__)

# smtplib mail
import sys

sys.path.append("/data/python/")
import data

# mail headers
app.config["MAIL_SERVER"] = data.MAIL_SERVER
app.config["MAIL_PORT"] = data.MAIL_PORT
app.config["MAIL_USE_TLS"] = False
app.config["MAIL_USE_SSL"] = True
app.config["MAIL_USERNAME"] = data.MAIL_USERNAME
app.config["MAIL_PASSWORD"] = data.MAIL_PASSWD
# mail message
app.config["MAIL_SUBJECT"] = "[bamboo web]"
app.config["MAIL_SENDER"] = data.MAIL_USERNAME
app.config["MAIL_ADMIN"] = data.MAIL_ADMIN

# sqlite db
basedir = os.path.abspath(os.path.dirname(__file__))
app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///" + os.path.join(basedir, "data.sqlite")
app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = True
app.config["SQLALCHEMY_COMMIT_ON_TEARDOWN"] = True
Example #14
0
import wikipedia
from werkzeug.security import generate_password_hash, check_password_hash

mail = Mail()

app = Flask(__name__)
app.config.from_object(__name__)

app.config["SQLALCHEMY_DATABASE_URI"] = settings.database_uri
db = SQLAlchemy(app)

app.secret_key = settings.app_secret_key

# Mail config

app.config["MAIL_SERVER"] = settings.mail["server"]
app.config["MAIL_PORT"] = settings.mail["port"]
app.config["MAIL_USE_SSL"] = settings.mail["use_ssl"]
app.config["MAIL_USERNAME"] = settings.mail["username"]
app.config["MAIL_PASSWORD"] = settings.mail["password"]

mail.init_app(app)


# Database Setup


class User(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    email = db.Column(db.String(120), unique=True)
    password = db.Column(db.String(100))
# 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 #16
0
#!/bin/env python

# Author Balbir Singh <balbir@aol.in>
# Date 15th September 2015


from flask import Flask
from flask.ext.mail import Mail, Message

app = Flask(__name__)
mail = Mail(app)

app.config["MAIL_SERVER"] = "email-smtp.us-east-1.amazonaws.com"
app.config["MAIL_PORT"] = 587
app.config["MAIL_USE_TLS"] = True
app.config["MAIL_USERNAME"] = "AKIAIWW4MPBTQP3K26VQ"
app.config["MAIL_PASSWORD"] = "AnPrQHdi8lUpmSNJQbfn8IYLpilti82gx73L7yTSkM4f"
app.config["FLASKY_MAIL_SUBJECT_PREFIX"] = "[Flasky]"
app.config["FLASKY_MAIL_SENDER"] = "Flasky Admin <flasky@goeuro.me>"
app.config["FLASKY_ADMIN"] = "balbir97@gmail.com"

msg = Message("test subject", sender="you@goeuro.me", recipients=["balbir97@gmail.com"])
msg.body = "text body"
msg.html = "<b>HTML</b> body"

with app.app_context():
    mail.send(msg)
__author__ = "gjp"
from flask import Flask, json, request, Response
from flask.ext.mail import Mail, Message
import httplib


app = Flask(__name__)
mail = Mail(app)

app.config["MAIL_SERVER"] = "mail.server.org"
app.config["MAIL_PORT"] = 465
app.config["MAIL_USERNAME"] = ""
app.config["MAIL_PASSWORD"] = ""
app.config["MAIL_USE_TLS"] = False
app.config["MAIL_USE_SSL"] = True

mail = Mail(app)

content_type = "application/json"


@app.route("/", methods=["POST"])
def index():
    try:
        bosun_json = json.loads(request.data)
    except ValueError:
        # Data is not a well-formed json
        message = "[{}] received {} from ip {}:{}".format(
            "-", json, request.environ["REMOTE_ADDR"], request.environ["REMOTE_PORT"]
        )
Example #18
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 #19
0
# coding=utf-8
import os
import random
import time
from flask import Flask, request, render_template, session, flash, redirect, url_for, jsonify
from flask.ext.mail import Mail, Message
from celery import Celery


app = Flask(__name__)
app.config["SECRET_KEY"] = "top-secret!"

# Flask-Mail configuration
app.config["MAIL_SERVER"] = "smtp.126.com"
app.config["MAIL_PORT"] = 25
app.config["MAIL_USE_TLS"] = True
app.config["MAIL_USERNAME"] = "ahuthulei"
app.config["MAIL_PASSWORD"] = "342426110shwill"
app.config["MAIL_DEFAULT_SENDER"] = "ahuthulei@126.com"

# Celery configuration
app.config["CELERY_BROKER_URL"] = "redis://localhost:6379/0"
app.config["CELERY_RESULT_BACKEND"] = "redis://localhost:6379/0"


# Initialize extensions
mail = Mail(app)

# Initialize Celery
celery = Celery(app.name, broker=app.config["CELERY_BROKER_URL"])
celery.conf.update(app.config)
Example #20
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 #21
0
def create_app(configfile=None):
    app = Flask(__name__)
    handler = RotatingFileHandler("urlabuse.log", maxBytes=10000, backupCount=5)
    handler.setFormatter(Formatter("%(asctime)s %(message)s"))
    app.wsgi_app = ReverseProxied(app.wsgi_app)
    app.logger.addHandler(handler)
    app.logger.setLevel(logging.INFO)
    Bootstrap(app)
    q = Queue(connection=conn)

    # Mail Config
    app.config["MAIL_SERVER"] = "localhost"
    app.config["MAIL_PORT"] = 25
    mail = Mail(app)

    app.config["SECRET_KEY"] = "devkey"
    app.config["BOOTSTRAP_SERVE_LOCAL"] = True
    app.config["configfile"] = config_path

    parser = configparser.SafeConfigParser()
    parser.read(app.config["configfile"])

    replacelist = make_dict(parser, "replacelist")
    auth_users = prepare_auth()
    ignorelist = [i.strip() for i in parser.get("abuse", "ignore").split("\n") if len(i.strip()) > 0]
    autosend_threshold = 5

    def _get_user_ip(request):
        ip = request.headers.get("X-Forwarded-For")
        if ip is None:
            ip = request.remote_addr
        return ip

    @app.route("/", methods=["GET", "POST"])
    def index():
        form = URLForm()
        return render_template("index.html", form=form)

    @app.route("/urlreport", methods=["GET"])
    def url_report():
        return render_template("url-report.html")

    @app.errorhandler(404)
    def page_not_found(e):
        ip = request.headers.get("X-Forwarded-For")
        if ip is None:
            ip = request.remote_addr
        if request.path != "/_result/":
            app.logger.info("404 of {} on {}".format(ip, request.path))
        return render_template("404.html"), 404

    def authenticate():
        """Sends a 401 response that enables basic auth"""
        return Response(
            "Could not verify your access level for that URL.\n" "You have to login with proper credentials",
            401,
            {"WWW-Authenticate": 'Basic realm="Login Required"'},
        )

    def check_auth(username, password):
        """This function is called to check if a username /
        password combination is valid.
        """
        if auth_users is None:
            return False
        else:
            db_pass = auth_users.get(username)
            return db_pass == password

    @app.route("/login", methods=["GET", "POST"])
    def login():
        auth = request.authorization
        if not auth or not check_auth(auth.username, auth.password):
            return authenticate()
        return redirect(url_for("index"))

    @app.route("/_result/<job_key>", methods=["GET"])
    def check_valid(job_key):
        if job_key is None:
            return json.dumps(None), 200
        job = Job.fetch(job_key, connection=conn)
        if job.is_finished:
            return json.dumps(job.result), 200
        else:
            return json.dumps("Nay!"), 202

    @app.route("/start", methods=["POST"])
    def run_query():
        data = json.loads(request.data)
        url = data["url"]
        ip = _get_user_ip(request)
        app.logger.info("{} {}".format(ip, url))
        if get_submissions(url) >= autosend_threshold:
            send(url, "", True)
        is_valid = q.enqueue_call(func=is_valid_url, args=(url,), result_ttl=500)
        return is_valid.get_id()

    @app.route("/urls", methods=["POST"])
    def urls():
        data = json.loads(request.data)
        url = data["url"]
        u = q.enqueue_call(func=url_list, args=(url,), result_ttl=500)
        return u.get_id()

    @app.route("/resolve", methods=["POST"])
    def resolve():
        data = json.loads(request.data)
        url = data["url"]
        u = q.enqueue_call(func=dns_resolve, args=(url,), result_ttl=500)
        return u.get_id()

    @app.route("/phishtank", methods=["POST"])
    def phishtank():
        data = json.loads(request.data)
        if not os.path.exists("phishtank.key"):
            return None
        url = parser.get("PHISHTANK", "url")
        key = open("phishtank.key", "r").readline().strip()
        query = data["query"]
        u = q.enqueue_call(func=phish_query, args=(url, key, query), result_ttl=500)
        return u.get_id()

    @app.route("/virustotal_report", methods=["POST"])
    def vt():
        data = json.loads(request.data)
        if not os.path.exists("virustotal.key"):
            return None
        url = parser.get("VIRUSTOTAL", "url_report")
        url_up = parser.get("VIRUSTOTAL", "url_upload")
        key = open("virustotal.key", "r").readline().strip()
        query = data["query"]
        u = q.enqueue_call(func=vt_query_url, args=(url, url_up, key, query), result_ttl=500)
        return u.get_id()

    @app.route("/googlesafebrowsing", methods=["POST"])
    def gsb():
        data = json.loads(request.data)
        if not os.path.exists("googlesafebrowsing.key"):
            return None
        url = parser.get("GOOGLESAFEBROWSING", "url")
        key = open("googlesafebrowsing.key", "r").readline().strip()
        url = url.format(key)
        query = data["query"]
        u = q.enqueue_call(func=gsb_query, args=(url, query), result_ttl=500)
        return u.get_id()

    @app.route("/urlquery", methods=["POST"])
    def urlquery():
        data = json.loads(request.data)
        if not os.path.exists("urlquery.key"):
            return None
        url = parser.get("URLQUERY", "url")
        key = open("urlquery.key", "r").readline().strip()
        query = data["query"]
        u = q.enqueue_call(func=urlquery_query, args=(url, key, query), result_ttl=500)
        return u.get_id()

    @app.route("/ticket", methods=["POST"])
    def ticket():
        if not request.authorization:
            return ""
        data = json.loads(request.data)
        server = parser.get("SPHINX", "server")
        port = int(parser.get("SPHINX", "port"))
        url = parser.get("ITS", "url")
        query = data["query"]
        u = q.enqueue_call(func=sphinxsearch, args=(server, port, url, query), result_ttl=500)
        return u.get_id()

    @app.route("/whois", methods=["POST"])
    def whoismail():
        if not request.authorization:
            return ""
        server = parser.get("WHOIS", "server")
        port = parser.getint("WHOIS", "port")
        data = json.loads(request.data)
        query = data["query"]
        u = q.enqueue_call(func=whois, args=(server, port, query, ignorelist, replacelist), result_ttl=500)
        return u.get_id()

    @app.route("/eupi", methods=["POST"])
    def eu():
        data = json.loads(request.data)
        if not os.path.exists("eupi.key"):
            return None
        url = parser.get("EUPI", "url")
        key = open("eupi.key", "r").readline().strip()
        query = data["query"]
        u = q.enqueue_call(func=eupi, args=(url, key, query), result_ttl=500)
        return u.get_id()

    @app.route("/pdnscircl", methods=["POST"])
    def dnscircl():
        url = parser.get("PDNS_CIRCL", "url")
        user, password = open("pdnscircl.key", "r").readlines()
        data = json.loads(request.data)
        query = data["query"]
        u = q.enqueue_call(func=pdnscircl, args=(url, user.strip(), password.strip(), query), result_ttl=500)
        return u.get_id()

    @app.route("/bgpranking", methods=["POST"])
    def bgpr():
        data = json.loads(request.data)
        query = data["query"]
        u = q.enqueue_call(func=bgpranking, args=(query,), result_ttl=500)
        return u.get_id()

    @app.route("/psslcircl", methods=["POST"])
    def sslcircl():
        url = parser.get("PSSL_CIRCL", "url")
        user, password = open("psslcircl.key", "r").readlines()
        data = json.loads(request.data)
        query = data["query"]
        u = q.enqueue_call(func=psslcircl, args=(url, user.strip(), password.strip(), query), result_ttl=500)
        return u.get_id()

    @app.route("/get_cache", methods=["POST"])
    def get_cache():
        data = json.loads(request.data)
        url = data["query"]
        data = cached(url)
        dumped = json.dumps(data, sort_keys=True, indent=4, separators=(",", ": "))
        return dumped

    def digest(data):
        to_return = ""
        all_mails = set()
        for entry in data:
            for url, info in list(entry.items()):
                to_return += "\n{}\n".format(url)
                if info.get("whois"):
                    all_mails.update(info.get("whois"))
                    to_return += "\tContacts: {}\n".format(", ".join(info.get("whois")))
                if info.get("vt") and len(info.get("vt")) == 4:
                    vtstuff = info.get("vt")
                    to_return += "\t{} out of {} positive detections in VT - {}\n".format(
                        vtstuff[2], vtstuff[3], vtstuff[1]
                    )
                if info.get("gsb"):
                    to_return += "\tKnown as malicious on Google Safe Browsing: {}\n".format(info.get("gsb"))
                if info.get("phishtank"):
                    to_return += "\tKnown as malicious on PhishTank\n"
                if info.get("dns"):
                    ipv4, ipv6 = info.get("dns")
                    if ipv4 is not None:
                        for ip in ipv4:
                            to_return += "\t" + ip + "\n"
                            data = info[ip]
                            if data.get("bgp"):
                                to_return += "\t\t(PTR: {}) is announced by {} ({}).\n".format(*(data.get("bgp")[:3]))
                            if data.get("whois"):
                                all_mails.update(data.get("whois"))
                                to_return += "\t\tContacts: {}\n".format(", ".join(data.get("whois")))
                    if ipv6 is not None:
                        for ip in ipv6:
                            to_return += "\t" + ip + "\n"
                            data = info[ip]
                            if data.get("whois"):
                                all_mails.update(data.get("whois"))
                                to_return += "\t\tContacts: {}\n".format(", ".join(data.get("whois")))
            to_return += "\tAll contacts: {}\n".format(", ".join(all_mails))
        return to_return

    def send(url, ip="", autosend=False):
        if not get_mail_sent(url):
            set_mail_sent(url)
            data = cached(url)
            if not autosend:
                subject = "URL Abuse report from " + ip
            else:
                subject = "URL Abuse report sent automatically"
            msg = Message(subject, sender="urlabuse@circl.lu", recipients=["info@circl.lu"])
            msg.body = digest(data)
            msg.body += "\n\n"
            msg.body += json.dumps(data, sort_keys=True, indent=4, separators=(",", ": "))
            mail.send(msg)

    @app.route("/submit", methods=["POST"])
    def send_mail():
        data = json.loads(request.data)
        url = data["url"]
        if not get_mail_sent(url):
            ip = _get_user_ip(request)
            send(url, ip)
        return redirect(url_for("index"))

    return app
Example #22
0
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
#    License for the specific language governing permissions and limitations
#    under the License.
import os
from flask import Flask, session


# db_path = os.path.abspath(
#    os.path.join(os.path.basename(__file__), "../"))

db_path = "tmp"

app = Flask(__name__)

app.config["MAILGUN_KEY"] = "#@#@#@#@"
app.config["MAILGUN_DOMAIN"] = "refstack.org"
app.config["SECRET_KEY"] = "#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@"
app.config["SQLALCHEMY_DATABASE_URI"] = os.environ.get("DATABASE_URL", "sqlite:///%s/refstack.db" % (db_path))
app.config["DEBUG"] = True
app.config["SECURITY_PASSWORD_HASH"] = "sha512_crypt"
app.config["SECURITY_PASSWORD_SALT"] = app.config["SECRET_KEY"]
app.config["SECURITY_POST_LOGIN_VIEW"] = "dashboard"
app.config["SECURITY_RECOVERABLE"] = True
app.config["SECURITY_REGISTERABLE"] = True
app.config["SECURITY_EMAIL_SENDER"] = "refstack.org"
app.config["MAIL_SERVER"] = "smtp.refstack.org"
app.config["MAIL_PORT"] = 465
app.config["MAIL_USE_SSL"] = True
app.config["MAIL_USERNAME"] = "postmaster@refstack.org"
app.config["MAIL_PASSWORD"] = "1234"
Example #23
0
from flask.ext.login import LoginManager

login_manager = LoginManager()
login_manager.init_app(app)


#####################################
## Mail
#####################################
if RUNTIME_ENV in ("bae",):
    from bae.api.bcms import BaeBcms

    BAE_BCMS = BaeBcms(const.ACCESS_KEY, const.SECRET_KEY)

elif RUNTIME_ENV in ("local",):
    app.config["MAIL_SERVER"] = "localhost"
    app.config["MAIL_PORT"] = 25
    app.config["MAIL_USE_TLS "] = False
    app.config["MAIL_USE_SSL "] = False
    app.config["MAIL_USERNAME "] = "test"
    app.config["MAIL_PASSWORD "] = "test"

    from flask_mail import Mail

    mail = Mail(app)

elif RUNTIME_ENV in ("gae", "gae_dev"):
    pass

#####################################
## Image Upload
Example #24
0
# rsvp_app.config.from_object('settings')  # Load from settings.py module

try:
    from settings_local import MAIL_SERVER
    from settings_local import MAIL_PORT
    from settings_local import MAIL_USE_TLS
    from settings_local import MAIL_USERNAME
    from settings_local import MAIL_PASSWORD
    from settings_local import DEFAULT_MAIL_SENDER
except ImportError:
    MAIL_SERVER = "localhost"
    MAIL_PORT = 25
    MAIL_USE_TLS = False
    MAIL_USERNAME = MAIL_PASSWORD = DEFAULT_MAIL_SENDER = None

rsvp_app.config["MAIL_SERVER"] = MAIL_SERVER
rsvp_app.config["MAIL_PORT"] = MAIL_PORT
rsvp_app.config["MAIL_USE_TLS"] = MAIL_USE_TLS
rsvp_app.config["MAIL_USERNAME"] = MAIL_USERNAME
rsvp_app.config["MAIL_PASSWORD"] = MAIL_PASSWORD
rsvp_app.config["DEFAULT_MAIL_SENDER"] = DEFAULT_MAIL_SENDER

mail = Mail(rsvp_app)

basedir = os.path.abspath(os.path.dirname(__file__))
rsvp_app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///" + os.path.join(basedir, "rsvp.db")  # 'sqlite:////tmp/test.db'
rsvp_app.config["SQLALCHEMY_MIGRATE_REPO"] = os.path.join(basedir, "db_repository")

db = SQLAlchemy(rsvp_app)
# CORS(rsvp_app)  # allow all origins
Example #25
0
from wtforms.validators import Required
from flask.ext.sqlalchemy import SQLAlchemy
from werkzeug import secure_filename
from werkzeug.security import generate_password_hash, check_password_hash
from flask.ext.mail import Mail, Message
from ftplib import FTP
from flask.ext.login import LoginManager, login_required

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

app = Flask(__name__)

"""
Note: setting these variables through the local environment & using os.environ to access them is preferred for security reasons
"""
app.config["MAIL_SERVER"] = ""
app.config["MAIL_PORT"] = ""
app.config["MAIL_USE_TLS"] = True
app.config["MAIL_USERNAME"] = "test@test.com"
app.config["MAIL_PASSWORD"] = "testpw"

app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///" + os.path.join(basedir, "data.sqlite")
# app.config['SQLALCHEMY_DATABASE_URI'] = os.environ['DATABASE_URL']
# uncomment this line if you want to use Heroku, comment instead the one before it
app.config["SQLALCHEMY_COMMIT_ON_TEARDOWN"] = True

app.config["UPLOAD_FOLDER"] = "./static/balls"

app.permanent_session_lifetime = timedelta(seconds=60)
app.config["SECRET_KEY"] = "veryhard2guess"
# be more original
Example #26
0
from flask import Flask, g
from flask.ext.sqlalchemy import SQLAlchemy
import sqlite3
import os

app = Flask(__name__)

app.secret_key = "development key"

app.config["MAIL_SERVER"] = "smtp.mail.yahoo.com"
app.config["MAIL_PORT"] = 465
app.config["MAIL_USE_SSL"] = True
app.config["MAIL_USERNAME"] = "igoriaustin@yahoo.com"
app.config["MAIL_PASSWORD"] = "efeosa"

from routes import mail

mail.init_app(app)

# DATABASE=os.path.join(app.root_path, 'testDB.db')
# DATABASE = 'testDB.db'
# DATABASE = 'C:/pythonvirtualenvironment/venv/app/database.db'
app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:////app/new.db"

from models import db

db.init_app(app)

import intro_to_flask.routes

# pp :igoriaustin@yahoo.com
Example #27
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 #28
0
)
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 #29
0
# coding: utf-8
import os, sys, hashlib, math

sys.path.append(os.path.dirname(__name__))

from flask import Flask
from flask import current_app
from flask.ext.mail import Mail
from flask.ext.mail import Message
from threading import Thread

app = Flask(__name__)
app.config.from_object(__name__)

# these configs must be set before creating mail instance
app.config["MAIL_SERVER"] = "smtp.qq.com"
app.config["MAIL_PORT"] = 25
app.config["MAIL_USE_TLS"] = True
app.config["MAIL_USE_SSL"] = False
app.config["MAIL_USERNAME"] = "36838082@qq.com"
app.config["MAIL_PASSWORD"] = "xx"
mail = Mail(app)


def send_async_email(app, msg):
    with app.app_context():
        mail.send(msg)


@app.route("/mail")
def SendMail():
Example #30
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.script import Shell
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.263.net"
app.config["MAIL_PORT"] = 25
app.config["MAIL_USE_TLS"] = False
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)