def should_be_able_to_work_without_providing_server_port_user_and_password_for_database_connection(self):
     app = Flask('newest_test')
     app.config['MONGOALCHEMY_DATABASE'] = 'my_database'
     db = MongoAlchemy(app)
     assert_equals(app.config['MONGOALCHEMY_SERVER'], 'localhost')
     assert_equals(app.config['MONGOALCHEMY_PORT'], '27017')
     assert_equals(app.config['MONGOALCHEMY_USER'], None)
     assert_equals(app.config['MONGOALCHEMY_PASSWORD'], None)
 def test_loads_without_database_connection_data(self):
     app = Flask(__name__)
     app.config['MONGOALCHEMY_DATABASE'] = 'my_database'
     MongoAlchemy(app)
     self.assertEqual(app.config['MONGOALCHEMY_SERVER'], 'localhost')
     self.assertEqual(app.config['MONGOALCHEMY_PORT'], '27017')
     self.assertEqual(app.config['MONGOALCHEMY_USER'], None)
     self.assertEqual(app.config['MONGOALCHEMY_PASSWORD'], None)
     self.assertEqual(app.config['MONGOALCHEMY_REPLICA_SET'], '')
 def test_should_be_able_to_work_without_providing_server_port_user_and_password_for_database_connection(self):
     app = Flask(__name__)
     app.config['MONGOALCHEMY_DATABASE'] = 'my_database'
     MongoAlchemy(app)
     self.assertEqual(app.config['MONGOALCHEMY_SERVER'], 'localhost')
     self.assertEqual(app.config['MONGOALCHEMY_PORT'], '27017')
     self.assertEqual(app.config['MONGOALCHEMY_USER'], None)
     self.assertEqual(app.config['MONGOALCHEMY_PASSWORD'], None)
     self.assertEqual(app.config['MONGOALCHEMY_REPLICA_SET'], '')
Example #4
0
def create_app():
    app = Flask(__name__)
    app.config.from_object('portal.settings')
    app.config['MONGOALCHEMY_DATABASE'] = 'portal'

    from portal.models import db
    db.init_app(app)

    from portal.login import door
    app.register_module(door)

    from portal.users import portal
    app.register_module(portal)

    return app
#                                             #
# Implements a server serving Bandit Problems #
#                                             #
###############################################
 
 
 
 
#############
# Databases #
#############
 
from flask.ext.mongoalchemy import MongoAlchemy
app = Flask(__name__)
app.config['DEBUG'] = True
app.config['MONGOALCHEMY_DATABASE'] = 'studentlib1'#change that name later
db = MongoAlchemy(app)
 
 
class Access(db.Document):
    """logs access to getcontext"""
    team_id = db.StringField()
    date = db.StringField()
    i = db.IntField()
    runid = db.IntField()
 
 
class PropPage(db.Document):
    """logs access to proposepage"""
    team_id = db.StringField()
    date = db.StringField()
from flask import Flask
from flaskext.mongoalchemy import MongoAlchemy
import string

app = Flask(__name__)
app.config['MONGOALCHEMY_DATABASE'] = 'task_collection'
app.config['SECRET_KEY'] = 'very secret, do you believe?'
app.config['DEBUG'] = True
db = MongoAlchemy(app)

from views import *
Example #7
0
import datetime
from pytz import timezone, UTC
import json
import re

from jinja2 import evalcontextfilter, Markup, escape

from flask import Flask, request, render_template, jsonify
from flaskext.mongoalchemy import MongoAlchemy
app = Flask(__name__)
app.config['DEBUG'] = True
app.config['MONGOALCHEMY_DATABASE'] = 'zarkov'
app.config['MONGOALCHEMY_SERVER'] = 'kilgore'
db = MongoAlchemy(app)

_paragraph_re = re.compile(r'(?:\r\n|\r|\n){2,}')

class Context(db.Document):
    config_collection_name = 'context'

    status = db.IntField()
    description = db.StringField()
    server = db.StringField()

class Extra(db.Document):
    config_collection_name = 'extra'

    stderr = db.StringField()
    stdout = db.StringField()

class Event(db.Document):
Example #8
0
from flask import Flask, url_for
from flask.ext.login import LoginManager
from flask.ext.uploads import UploadSet, configure_uploads, IMAGES, UploadNotAllowed
from flask.ext.mongoalchemy import MongoAlchemy
from flask.ext.gravatar import Gravatar
from flask.ext.admin import Admin, BaseView, expose
import os

app = Flask(__name__)
app.config['DEBUG']                 = True
app.config['MONGOALCHEMY_DATABASE'] = 'test'
app.config['SECRET_KEY']            = 'somesecretkey'
app.config['UPLOADED_FILES_DEST']   = os.getcwd() + '/stone/static/files'

db            	= MongoAlchemy(app)
gravatar      	= Gravatar(app, size=64, rating='g', default='retro', force_default=False, force_lower=False)
files         	= UploadSet('files', IMAGES)
login_manager 	= LoginManager()

login_manager.init_app(app)
configure_uploads(app, files)

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

def datetimeformat(value, format='%H:%M / %d-%m-%Y'):
    return value.strftime(format)

app.jinja_env.filters['datetimeformat'] = datetimeformat
Example #9
0
import datetime
from copy import deepcopy
from flask import Flask
from flask import request, url_for, render_template
from flaskext.mongoalchemy import MongoAlchemy
import shelve
import feedparser
import plivo
import sys
import re
import twitter
from HTMLParser import HTMLParser
app = Flask(__name__)
app.config.from_object('config')
app.config['MONGOALCHEMY_DATABASE'] = 'watchTest'
db = MongoAlchemy(app)

c_key = app.config('CONSUMER_KEY')
c_secret = app.config('CONSUMER_SECRET')
a_t_key = app.config('ACCESS_TOKEN_KEY')
a_t_secret = app.config('ACCESS_TOKEN_SECRET')

api = twitter.Api(consumer_key=c_key, 
consumer_secret=c_secret, 
access_token_key=a_t_key, 
access_token_secret=a_t_secret)

auth_id = app.config('AUTH_ID')
auth_token = app.config('AUTH_TOKEN')
    
 def test_should_be_able_to_create_two_decoupled_mongoalchemy_instances(self):
     app = Flask(__name__)
     app.config['MONGOALCHEMY_DATABASE'] = 'my_database'
     db1 = MongoAlchemy(app)
     db2 = MongoAlchemy(app)
     assert db1.Document is not db2.Document, "two documents should not be the same object"
Example #11
0
from flask_mongoalchemy import MongoAlchemy, BaseQuery
from flask import Flask
 
crawler =  Flask(__name__)
crawler.secret_key = 'continents9794'
crawler.config['MONGOALCHEMY_DATABASE'] = 'website-scraper'
crawler.config['MONGOALCHEMY_CONNECTION_STRING'] = 'mongodb://scraper:continents@ds023495.mlab.com:23495/website-scraper'

db = MongoAlchemy(crawler)

class db_query(BaseQuery) :
	def text_query(self, url) :
		return self.filter(self.type.sites == url).fields('text')

	def images_query(self, url) :
		return self.filter(self.type.sites == url).fields('images')

	def links_query(self, url) :
		return self.filter(self.type.sites == url).fields('links')

	def indent_query(self, url) :
		return self.filter(self.type.sites == url).fields('indent')

class images_db(db.Document) :
	query_class = db_query
	sites       = db.StringField()
	images      = db.ListField(db.StringField())

class links_db(db.Document) :
	query_class = db_query
	sites       = db.StringField()
Example #12
0
# api.py - Simplisic Flask APP at the moment

from flask import Flask
from flask.ext.mongoalchemy import MongoAlchemy

app = Flask(__name__)

app.config['MONGOALCHEMY_DATABASE'] = 'overhear'
db = MongoAlchemy(app)

class Overhear(db.Document):
    name = db.StringField()


@app.route('/')
def hello_world():
    return 'Hello World!'

if __name__ == '__main__':
    app.run()
Example #13
0
log = getLogger()

app = Flask(__name__)
app.debug = True
# Configuracion de app.
app.config['SECRET_KEY'] = 'super-secret'
app.config['JWT_REQUIRED_CLAIMS'] = []
app.config['JWT_EXPIRATION_DELTA'] =  timedelta(hours=12)
app.config['BUNDLE_ERRORS'] = True
app.config['SEND_EMAILS'] = True

# Configuracion de MongoDB.
url = os.environ.get('MONGOLAB_URI', 'mongodb://localhost/enjoy-events')
app.config['MONGOALCHEMY_CONNECTION_STRING'] = url
parsed = urlsplit(url)
app.config['MONGOALCHEMY_DATABASE'] = parsed.path[1:]
db = MongoAlchemy(app)


CORS(app)


errors = {
   'SpecsError': {
       'message': "This field can't be empty.",
       'status': 401,
   },
   'ValidationError': {
       'message': "This field can't be empty.",
       'status': 402,
   },
Example #14
0
FACEBOOK_APP_ID = '339967149444676'
FACEBOOK_APP_SECRET = 'aa7cafd863dc9533f42a3d9c31f6b802'
TWITTER_APP_ID = '4TTmTkkoDqUuxsDhKYzXQ'
TWITTER_APP_SECRET = 'nebfZIBjCa8VnKxkf2KVe76EjtFbEalGr5DPqa7YU9A'


_is_deploy = True
if socket.gethostname() in ['au01rh00122','SteMac.local']: _is_deploy = False


app = Flask(__name__)
if _is_deploy:
    app.config['MONGOALCHEMY_SERVER'] = os.environ['OPENSHIFT_MONGODB_DB_HOST']
    app.config['MONGOALCHEMY_USER'] = os.environ['OPENSHIFT_MONGODB_DB_USERNAME']
    app.config['MONGOALCHEMY_PASSWORD'] = os.environ['OPENSHIFT_MONGODB_DB_PASSWORD']
    app.config['MONGOALCHEMY_DATABASE'] = os.environ['OPENSHIFT_APP_NAME']
else:
    app.config['MONGOALCHEMY_DATABASE'] = 'watchit'

db = MongoAlchemy(app)

from User import User

oauth = OAuth()
twitter = oauth.remote_app('twitter',
    base_url='https://api.twitter.com/1/',
    request_token_url='https://api.twitter.com/oauth/request_token',
    access_token_url='https://api.twitter.com/oauth/access_token',
    authorize_url='https://api.twitter.com/oauth/authenticate',
    consumer_key=TWITTER_APP_ID,
    consumer_secret=TWITTER_APP_SECRET,
A simple application that shows how Flask and jQuery get along.

:copyright: (c) 2010 by Armin Ronacher.
:license: BSD, see LICENSE for more details.
"""

# INIT

from __future__ import division
from flask import Flask, jsonify, render_template, request, redirect, url_for, session
from flaskext.mongoalchemy import MongoAlchemy
import urllib, json, score_calculation, fetch_fb_functions, datetime

app = Flask(__name__)
app.config['DEBUG'] = True
app.config['MONGOALCHEMY_DATABASE'] = 'fb_close_friends'
db = MongoAlchemy(app)

# DOCUMENTS

class Score(db.Document):
    friend_uid = db.StringField()
    score = db.FloatField()

class User(db.Document):
    uid = db.StringField()
    modified_time = db.ModifiedField()
    set_of_scores = db.ListField(db.DocumentField(Score), min_capacity=0, max_capacity=20)

# METHODS
Example #16
0
from flaskext.script import Manager
from flaskext.mongoalchemy import MongoAlchemy
import os, datetime

#------------
# App Config
#------------
app = Flask(__name__)
app.config["SECRET_KEY"] = "asdf"
app.config['DEBUG'] = False
app.config["DEBUG_TB_INTERCEPT_REDIRECTS"] = False
app.config["CACHE_TYPE"] = 'simple'
toolbar = DebugToolbarExtension(app)

# Database URI - sqlite3 for testing
app.config['MONGOALCHEMY_DATABASE'] = 'tweeter'

# Password hashing configuration
app.config['BCRYPT_SALT_ROUNDS'] = 12

# Declare database object
db = MongoAlchemy(app)

# Setup login managers
login_manager = LoginManager()
login_manager.setup_app(app)
login_manager.login_view = "login"


#---------------
# JS/CSS Assets
Example #17
0
@app.after_request
def add_headers(response):
    if isinstance(response.data, dict) or isinstance(response.data, list):
        response.headers['Content-Type'] = 'application/json'
    response.headers.add_header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE,OPTIONS,HEAD')
    response.headers.add_header('Access-Control-Allow-Origin', '*')
    response.headers.add_header('Access-Control-Allow-Headers', 'Content-Type,Authorization')
    print 'response headers are %s' % response.headers
    return response

# Initialize the MongoDB connection info and set it onto the app for flask-mongoalchemy
app.config['MONGOALCHEMY_SERVER'] = os.environ.get('OPENSHIFT_MONGODB_DB_HOST', 'localhost')
# Notice how we read the env variables setup by the MongoDB cartridge
app.config['MONGOALCHEMY_PORT'] = int(os.environ.get('OPENSHIFT_MONGODB_DB_PORT', 27017))
app.config['MONGOALCHEMY_DATABASE'] = os.environ.get('MONGO_DB', 'demodb')
app.config['MONGOALCHEMY_USER'] = os.environ.get('OPENSHIFT_MONGODB_DB_USERNAME')
app.config['MONGOALCHEMY_PASSWORD'] = os.environ.get('OPENSHIFT_MONGODB_DB_PASSWORD')
app.config['MONGOALCHEMY_SERVER_AUTH'] = True

db = MongoAlchemy(app)

# A secret key should be setup for OpenShift
app.secret_key = str(uuid.uuid4())
DEBUG = True

# Again, the redis cartridge requires these environment variables
redis_cli = redis.Redis(host=os.environ.get('OPENSHIFT_REDIS_HOST', 'localhost'), 
        port=int(os.environ.get('OPENSHIFT_REDIS_PORT', '6379')),
        password=os.environ.get('REDIS_PASSWORD', None))
import json

from flask import Flask, jsonify, request, Response
from flaskext.mongoalchemy import MongoAlchemy


ENDPOINT = 'http://data.nasa.gov/api/'

app = Flask(__name__)
app.config['MONGOALCHEMY_DATABASE'] = 'nasadata'
db = MongoAlchemy(app)

# These imports must be below the db definition
from api.parsers import datanasa
from api.parsers.datanasa import Dataset, Tag
from api.parsers import grin
from api.parsers.grin import Grin
from api.parsers import kepler

# FIXME: Need to call an 'update' function which loops and gets each dataset
datanasa.get_dataset(619)

def hacky_jsonify_list(data_list):
    # this can be replaced by providing a serialization methods on the Dataset
    # and the DatasetQuery objects
    return Response(json.dumps(data_list), mimetype='application/json')

@app.route('/', methods=['GET'])
def index():
    datasets = datanasa.Dataset.query.all()
    response = []
Example #19
0
    :license: BSD, see LICENSE for more details.
"""

import os

from flask import Flask, request, session, g, redirect, url_for, abort, \
     render_template, flash

from flask.ext.mongoalchemy import MongoAlchemy


# create our little application :)
app = Flask(__name__)

app.config['DEBUG'] = True
app.config['MONGOALCHEMY_DATABASE'] = 'weibo'
app.config['SECRET_KEY']='development key'
app.config['USERNAME']='admin'
app.config['PASSWORD']='default'

db = MongoAlchemy(app)

class Twitter(db.Document):
    title = db.StringField()
    text = db.StringField()



@app.route('/')
def show_entries():
    
Example #20
0
from xml.dom import minidom

import cPickle as pickle

from flaskext.mongoalchemy import MongoAlchemy

from models import Call, SMS, Trax
from call import CallStateMachDaddy

from functools import wraps
#import pymongo.objectid


app = Flask(__name__)
app.config.from_object('config')
app.config['MONGOALCHEMY_DATABASE'] = 'callz'
db = MongoAlchemy(app)

song_urls=['http://50.116.10.109/~csik/plivo_sounds/old_skool.mp3',
          'http://50.116.10.109/~csik/plivo_sounds/reggae_1.mp3',
          'http://50.116.10.109/~csik/plivo_sounds/swing.mp3',
          'http://50.116.10.109/~csik/plivo_sounds/vibrant_thing.mp3',
          'http://50.116.10.109/~csik/plivo_sounds/afro_classic.mp3',]

@app.route("/")
def hello():
    return "A very serious Hello World."
    
#wrapper to get call and daddy    
def get_objects(function):
    @wraps(function)
Example #21
0
from flask import Flask
from flask.ext.mongoalchemy import MongoAlchemy

# Create mongo_app
mongo_app = Flask('__name__')
mongo_app.config['MONGOALCHEMY_SERVER'] = 'ds027908.mongolab.com'
mongo_app.config['MONGOALCHEMY_SERVER_AUTH'] = False
mongo_app.config['MONGOALCHEMY_DATABASE'] = 'siberian'
mongo_app.config['MONGOALCHEMY_PORT'] = '27908'
mongo_app.config['MONGOALCHEMY_USER'] = "admin"
mongo_app.config['MONGOALCHEMY_PASSWORD'] = 'zarman12'

# Create database connection object
mongo = MongoAlchemy(mongo_app)
Example #22
0
from flask import Flask, jsonify
from flask.ext.mongoalchemy import MongoAlchemy
from bson.objectid import ObjectId


app = Flask(__name__)
app.config['MONGOALCHEMY_DATABASE'] = 'hacktx'
db = MongoAlchemy(app)

class Course(db.Document):
    deptAb = db.StringField()
    deptName = db.StringField()
    courseNum = db.StringField()
    courseName = db.StringField()
    teacherName = db.StringField()

class StudyInstance(db.Document):
	building = db.StringField()
	gpsCoords = db.StringField()
	courseID = db.DocumentField(Course)
	notes = db.StringField()


@app.route('/search/dept/<ab>')
def search_dept(ab):
 	c = Course.query.filter(Course.deptAb == ab).all()
 	l = []
 	for course in c:
 		l.append([course.courseNum, course.courseName])
	return jsonify(l)
Example #23
0
# Importing packages and modules
from flask import Flask, render_template
from flask.ext.mongoalchemy import MongoAlchemy


# Setup "app" as per Flask.
app = Flask(__name__)
app.config['MONGOALCHEMY_DATABASE'] = 'travelabulous'

# Hook an ORM to the app. We are using MongoAlchemy
db = MongoAlchemy(app)


## MODEL DEFINITION START

class Option(db.Document):
  text = db.StringField(required = True)
  isPictureOption = db.BoolField(required = True)

  def __unicode__(self):
    return self.text
  def __str__(self):
        return unicode(self).encode('utf-8')


class Question(db.Document):
  text = db.StringField(required = True)
  options = db.ListField(db.DocumentField('Option'), required = False)

  def __unicode__(self):
    return self.text
Example #24
0

@app.after_request
def add_headers(response):
    if isinstance(response.data, dict) or isinstance(response.data, list):
        response.headers['Content-Type'] = 'application/json'
    response.headers.add_header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE,OPTIONS,HEAD')
    response.headers.add_header('Access-Control-Allow-Origin', '*')
    response.headers.add_header('Access-Control-Allow-Headers', 'Content-Type,Authorization')
    print 'response headers are %s' % response.headers
    return response

#TODO move this back to storage.__init__
app.config['MONGOALCHEMY_SERVER'] = os.environ.get('OPENSHIFT_MONGODB_DB_HOST', 'localhost')
app.config['MONGOALCHEMY_PORT'] = int(os.environ.get('OPENSHIFT_MONGODB_DB_PORT', 27017))
app.config['MONGOALCHEMY_DATABASE'] = os.environ.get('MONGO_DB', 'wrestlerdb')
app.config['MONGOALCHEMY_USER'] = os.environ.get('OPENSHIFT_MONGODB_DB_USERNAME')
app.config['MONGOALCHEMY_PASSWORD'] = os.environ.get('OPENSHIFT_MONGODB_DB_PASSWORD')
app.config['MONGOALCHEMY_SERVER_AUTH'] = True

db = MongoAlchemy(app)

app.secret_key = str(uuid.uuid4())
DEBUG = True

redis_cli = redis.Redis(host=os.environ.get('OPENSHIFT_REDIS_HOST', 'localhost'), 
        port=int(os.environ.get('OPENSHIFT_REDIS_PORT', '6379')),
        password=os.environ.get('REDIS_PASSWORD', None))

import os
from flask.ext.login import LoginManager
from flask import Flask
from flaskext.mongoalchemy import MongoAlchemy
import string

app = Flask(__name__)
app.config['MONGOALCHEMY_DATABASE'] = 'books_collection'
app.config['SECRET_KEY'] = 'very secret, do you believe?'
app.config['DEBUG'] = True
db = MongoAlchemy(app)

@app.context_processor
def put_letters_on_request():
    return { 'letters' : string.ascii_uppercase }

from views import *
Example #26
0
from flask import Flask
from flask.ext.mongoalchemy import MongoAlchemy
import os
app = Flask(__name__)

MONGO_URL = os.environ.get('MONGOLAB_URI')
print("MONGOLAB_URI", MONGO_URL)
if MONGO_URL:
  # Get client
  print("Connected with MONGO_URL")
  app.config['MONGOALCHEMY_CONNECTION_STRING'] = MONGO_URL
  app.config['MONGOALCHEMY_DATABASE'] = 'heroku_xzpnfqgh'
else:
  print("Connected with local")
  # Not on an app with the MongoHQ add-on, do some localhost action
  app.config['MONGOALCHEMY_DATABASE'] = 'library'

db = MongoAlchemy(app)

class Mesurement(db.Document):
    temp = db.FloatField()
    light = db.FloatField()
    wind_speed = db.FloatField()
    press = db.FloatField()
    date = db.DateTimeField()
    voltage = db.FloatField()
    team = db.IntField()

class Clothes(db.Document):
    temp = db.FloatField()
    name = db.StringField()
Example #27
0
# -*- coding: utf-8 -*-

# Copyright 2010 flask-mongoalchemy authors. All rights reserved.
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.

from flask import Flask, request
from flaskext.mongoalchemy import MongoAlchemy
app = Flask(__name__)
app.config['DEBUG'] = True
app.config['MONGOALCHEMY_DATABASE'] = 'library'
db = MongoAlchemy(app)

class Author(db.Document):
    name = db.StringField()

class Book(db.Document):
    title = db.StringField()
    author = db.DocumentField(Author)
    year = db.IntField()

@app.route('/author/new')
def new_author():
    """Creates a new author by a giving name (via GET parameter)

    e.g.: GET /author/new?name=Francisco creates a author named Francisco
    """
    author = Author(name=request.args.get('name', ''))
    author.save()
    return 'Saved :)'
Example #28
0
        request.data = json.loads(request.data)


@app.after_request
def add_headers(response):
    if isinstance(response.data, dict) or isinstance(response.data, list):
        response.headers['Content-Type'] = 'application/json'
    response.headers.add_header('Access-Control-Allow-Origin', '*')
    response.headers.add_header('Access-Control-Allow-Headers', 'Content-Type')
    print 'response headers are %s' % response.headers
    return response

#TODO move this back to storage.__init__
app.config['MONGOALCHEMY_SERVER'] = os.environ.get('OPENSHIFT_MONGODB_DB_HOST', 'localhost')
app.config['MONGOALCHEMY_PORT'] = int(os.environ.get('OPENSHIFT_MONGODB_DB_PORT', 27017))
app.config['MONGOALCHEMY_DATABASE'] = os.environ.get('MONGO_DB', 'scribble')
app.config['MONGOALCHEMY_USER'] = os.environ.get('OPENSHIFT_MONGODB_DB_USERNAME')
app.config['MONGOALCHEMY_PASSWORD'] = os.environ.get('OPENSHIFT_MONGODB_DB_PASSWORD')
app.config['MONGOALCHEMY_SERVER_AUTH'] = True
app.config['REDIS_SERVER'] = os.environ.get('OPENSHIFT_REDIS_HOST', 'localhost')
app.config['REDIS_PORT'] = int(os.environ.get('OPENSHIFT_REDIS_PORT', '6379'))

db = MongoAlchemy(app)

scrib_shots = db.session.db.connection.scribble_shots
scrib_grid = GridFS(scrib_shots)

def make_celery(app):
    celery = Celery(app.import_name, broker=app.config['CELERY_BROKER_URL'])
    celery.conf.update(app.config)
    """
Example #29
0
from gevent import monkey
monkey.patch_all()
from gevent.event import Event
from gevent.pywsgi import WSGIServer

from flask import Flask, render_template, jsonify, request
from flaskext.mongoalchemy import MongoAlchemy



app = Flask(__name__, template_folder='views')
app.config['MONGOALCHEMY_DATABASE'] = 'simpoll'
db = MongoAlchemy(app)

event = Event()

class Person(db.Document):
  name = db.StringField()

  def to_dict(self):
    return {
          'id': str(self.mongo_id),
          'name': self.name,
        }


@app.route('/persons/<person_id>', methods=['DELETE'])
def person_route(person_id):
  if request.method.upper() == 'DELETE':
    person = Person.query.get(person_id)
    person.remove()
Example #30
0
from flask import Flask
from flaskext.mongoalchemy import MongoAlchemy
from  models import SMS, User, Status


app = Flask(__name__)
app.config.from_pyfile('config.py')
app.config['MONGOALCHEMY_DATABASE'] = 'smsTest2'
db = MongoAlchemy(app)

import views
import utilities

if __name__ == "__main__":
    app.run()