#Init file

from flask import Flask
from flask.ext.pymongo import PyMongo
from flask.ext.mongokit import MongoKit, Document, Connection
from flask.ext.login import LoginManager

app = Flask(__name__)

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

app.config.from_object('config')

#Mongo Connection
app.config["MONGO_DATABASE"] = 'couponext'
app.config["MONGO_HOST"] = '127.0.0.1'
app.config["MONGO_PORT"] = 27017

mongo = MongoKit(app)

from app import views
Beispiel #2
0
from flask import Flask, render_template, request, redirect, abort, jsonify
from flask.ext.pymongo import PyMongo
from ast import literal_eval
import json
import pymongo
from bson.json_util import dumps
import hashlib

#end authentication
app = Flask(__name__)
app.config["MONGO_DBNAME"] = "habigotchi"
app.config["MONGO_HOST"] = "oceanic.mongohq.com"
app.config["MONGO_PORT"] = 10008
app.config["MONGO_USERNAME"] = "admin"
app.config["MONGO_PASSWORD"] = "1234"
app.debug= True
mongo = PyMongo(app)

m = hashlib.sha256

def authenticate(user, pw):
    users = mongo.db.users
    hashed = m(user+pw).hexdigest()
    return users.find_one({"password": hashed}) != None

@app.route('/', methods=['GET', 'POST'])
def landing():
    if request.method == 'POST':
        users = mongo.db.users
        check = users.find_one({"name":request.form['name']})
        if check != None:
Beispiel #3
0
from flask import Flask
#from flask.ext.pymongo import PyMongo
app=Flask(__name__)


from views import *
"""
from pymongo import MongoClient



client = MongoClient("colab-sbx-280.oit.duke.edu", "27017")
db = client.hackmit
"""



app.config["MONGO_HOST"] = "mongodb://colab-sbx-280.oit.duke.edu:27107"
app.config["MONGO_PORT"] = 27017
app.config["MONGO_DBNAME"] = "hackmit"
mongo = PyMongo(app)



#not sure what this line does, will ignore for now.. O:)
#app.config.from_object(__name__)

app.run()

Beispiel #4
0
from flask import jsonify
from flask import request
from flask.ext.cors import CORS
from flask.ext.pymongo import PyMongo

from localsettings import DBNAME
from localsettings import HOST
from localsettings import PORT
from localsettings import USERNAME
from localsettings import PASSWORD


app = Flask(__name__)

app.config["MONGO_DBNAME"] = DBNAME
app.config["MONGO_HOST"] = HOST
app.config["MONGO_PORT"] = PORT
app.config["MONGO_USERNAME"] = USERNAME
app.config["MONGO_PASSWORD"] = PASSWORD
mongo = PyMongo(app, config_prefix="MONGO")

CORS(
    app,
    resources={
        r"/contact/*": {"origins": [r".*aomercado\.github\.io", r".*aomercado\.com"]},
        r"/market/*": {"origins": [r".*aomercado\.github\.io", r".*aomercado\.com"]},
    },
)


@app.route("/contact", methods=["POST"])
from flask import Flask, Response
from flask.ext.pymongo import PyMongo
import json
from settings import *

app = Flask(__name__)
app.config["MONGO_HOST"] = CONFIG["mongo"]["host"]
app.config["MONGO_DBNAME"] = CONFIG["mongo"]["db"]
if CONFIG["mongo"].has_key("uri"):
    app.config["MONGO_URI"] = CONFIG["mongo"]["uri"]

mongo = PyMongo(app)


@app.route("/palavra/<palavra>")
def define(palavra):
    dicionario = mongo.db[CONFIG["mongo"]["collection"]]
    resultado = dicionario.find_one_or_404({"palavra": palavra})
    resultado.pop("_id")
    resp = Response(json.dumps(resultado), status=200, mimetype="application/json")
    resp.headers["Access-Control-Allow-Origin"] = "*"
    return resp


if __name__ == "__main__":
    app.run(debug=True)
Beispiel #6
0
import config
from flask import Flask
from flask.ext.pymongo import PyMongo

myapp = Flask(__name__,static_folder='../public/static')
myapp.config["MONGO_HOST"] = config.MONGO_HOST
myapp.config["MONGO_PORT"] = config.MONGO_PORT
myapp.config["MONGO_DBNAME"] = config.MONGO_DBNAME
myapp.config["MONGO_USERNAME"] = config.MONGO_USERNAME
myapp.config["MONGO_PASSWORD"] = config.MONGO_PASSWORD
mongo = PyMongo(myapp)

import views
Beispiel #7
0
import json
import bson
import requests
import collections
from ipwhois import IPWhois
import pymongo
import whois
import re
import ast
from bson.son import SON

#################
# Configuration #
#################
app = Flask(__name__)
app.config["MONGO_HOST"] = "localhost"
app.config["MONGO_PORT"] = 27017
app.config["MONGO_DBNAME"] = "threatnote"

mongo = PyMongo(app, config_prefix="MONGO")

###################
# Creating routes #
###################


@app.route("/", methods=["GET"])
def home():
    try:
        networks = convert(mongo.db.network.distinct("campaign"))
        dictcount = {}
Beispiel #8
0
from flask import Flask, render_template, request, redirect, abort
from flask.ext.pymongo import PyMongo
#from Flask-PyMongo import PyMongo
import pymongo
from bson.objectid import ObjectId
from pymongo import ASCENDING, DESCENDING

app = Flask(__name__)
app.config["MONGO_DBNAME"] = "cats"
app.config["MONGO_HOST"] = "linus.mongohq.com"
app.config["MONGO_PORT"] = 10042
app.config["MONGO_USERNAME"] = "hello"
app.config["MONGO_PASSWORD"] = "world"
app.config["SECRET_KEY"] = "KeepThisS3cr3t"
app.config["SEND_FILE_MAX_AGE_DEFAULT"] = 0
mongo = PyMongo(app)

@app.route('/')
def index():
    posts = mongo.db.posts.find().sort("views", DESCENDING)
    return render_template('index.html', posts = posts)

@app.route('/submit', methods=['GET', 'POST'])
def submit():
    if request.method == 'POST':
        post = {"author": request.form['author'], 
        "title": request.form['title'], "text": request.form['text'], "cat":
        request.form['cat']}
        posts = mongo.db.posts
        post_id = posts.insert(post)
        return redirect('/cat/' + str(post_id))
Beispiel #9
0
console_format = logging.Formatter(" %(asctime)s %(levelname)s: %(message)s [in %(module)s:%(lineno)d]")
console_logger.setFormatter(console_format)
console_logger.setLevel(logging.WARNING)
app.logger.addHandler(console_logger)


if os.environ.get("EXTERNAL"):
    app.config["MONGO_URI"] = os.environ["MONGO_URI"]
    app.config["MONGO_CONNECT"] = False
    app.secret_key = os.environ["random_key"]
    app.config["BROKER_URL"] = os.environ["REDIS_URL"]  # Celery
    app.config["CELERY_RESULT_BACKEND"] = os.environ["REDIS_URL"]
else:
    with open("../Other-Secrets/TITDev.json") as secrets_file:
        secrets = json.load(secrets_file)
    app.config["MONGO_HOST"] = secrets["mongo-host"]
    app.config["MONGO_DBNAME"] = secrets["mongo-db"]
    app.config["MONGO_USERNAME"] = secrets["mongo-user"]
    app.config["MONGO_PASSWORD"] = secrets["mongo-password"]
    app.config["MONGO_PORT"] = secrets["mongo-port"]
    app.config["BROKER_URL"] = secrets["redis-host"]  # Celery
    app.config["CELERY_RESULT_BACKEND"] = secrets["redis-host"]
    app.config["MONGO_CONNECT"] = False
    app.secret_key = secrets["random_key"]

Bootstrap(app)
cdn_theme_url = "https://maxcdn.bootstrapcdn.com/bootswatch/3.3.5/slate/"
app.extensions['bootstrap']['cdns']["theme"] = WebCDN(cdn_theme_url)  # CDN Theme
app_mongo = PyMongo(app)

# Redis
Beispiel #10
0
from flask import Flask, render_template, jsonify, url_for, redirect, request
from flask.ext.cors import CORS
from flask_pymongo import PyMongo
from flask_restful import Api, Resource
from data_builder.data_builder import *

# Create app and connect to MongoDB
application = Flask(__name__)
application.config["MONGO_HOST"] = "mongoContainer"
application.config["MONGO_DBNAME"] = "setlists"
application.config['SERVER_NAME'] = 'setlist.visualizer'
application.config["MONGO_CONNECT"] = False
mongo = PyMongo(application, config_prefix='MONGO')


# Get concert dates for available artist
class Shows(Resource):
    def get(self, artist=None):

        # If an artist is passed in, grab all shows from MongoDB.
        if artist:
            shows = get_shows(mongo, artist, request.args)
            if shows['total']:
                return jsonify({"status": "ok", "data": shows})
        return {"status": "fail", "data": "No shows found for artist {0}".format(artist)}


# Get list of all tours
class Tours(Resource):
    def get(self, artist=None):