Example #1
1
    def setUp(self):
        app = Flask(__name__)
        app.config.from_object(settings)
        app.testing = True
        app.config["MONGO_DBNAME"] = "bergenholmtest"
        database.init_db(app)

        app.register_blueprint(frontend, url_prefix="")
        app.register_blueprint(ipxe, url_prefix="/ipxe")
        app.register_blueprint(hosts, url_prefix="/api/1.0/hosts")
        app.register_blueprint(groups, url_prefix="/api/1.0/groups")
        app.register_blueprint(templates, url_prefix="/api/1.0/templates")
        app.register_blueprint(power, url_prefix="/api/1.0/power")

        self.app = app
        self.client = app.test_client()
        self.mongo = database.mongo

        with self.app.test_request_context("/"):
            self.mongo.db.hosts.remove()
            self.mongo.db.groups.remove()
            self.mongo.db.templates.remove()

            params = {u"_id": self.host_id}
            params.update(self.host_params)
            self.mongo.db.hosts.insert(params)

            self.mongo.db.groups.insert({u"_id": u"default", u"base_url": u"http://127.0.0.1"})

            params = {u"_id": self.group_id}
            params.update(self.group_params)
            self.mongo.db.groups.insert(params)

            self.mongo.db.templates.insert({u"_id": self.template_id, u"content": self.template})
Example #2
0
def create_app(dbname="damnmummies"):
    app = Flask(__name__)

    app.config["MONGO_DBNAME"] = dbname
    mongo.init_app(app)

    app.register_blueprint(game_blueprint)

    return app
Example #3
0
def create_app(dbname="whose_turn"):
    app = Flask("whose_turn")

    app.config["MONGO_DBNAME"] = dbname
    mongo.init_app(app)

    app.register_blueprint(api_blueprint, url_prefix="/api")

    return app
Example #4
0
def create_app(db_interface, app_name="testapp", db_name="__test-db__"):
    app = Flask(app_name)
    app.config["SERVER_NAME"] = "localhost:5000"

    if db_interface == "pymongo":
        app.config["MONGO_DBNAME"] = db_name
        mongo = PyMongo(app)
        with app.app_context():
            app.session_interface = MongoDBSessionInterface(app, mongo.db, "sessions")
    elif db_interface == "mongoengine":
        app.config["MONGODB_DB"] = db_name
        mongo = MongoEngine(app)
        app.session_interface = MongoDBSessionInterface(app, mongo.connection[app.config["MONGODB_DB"]], "sessions")

    @app.route("/set")
    def set_session():
        session["data"] = request.args["d"]
        return "data"

    @app.route("/setpermanent")
    def set_permanent_session():
        session.permanent = True
        session["data"] = request.args["d"]
        return "data"

    @app.route("/get")
    def get_session():
        return session.get("data", "")

    @app.route("/unicode/set")
    def unicode_set():
        session["foo"] = u"Alpenerstra\xdfe"
        return "done"

    @app.route("/unicode/get")
    def unicode_get():
        return session["foo"]

    return app
Example #5
0
from flask import request
from datetime import datetime
import simplejson
from bson.json_util import dumps
from bson.objectid import ObjectId
from flask.ext.api import status


EMOTION_SAD = "sad"
EMOTION_FRUSTRATED = "frustrated"
EMOTION_ANGRY = "angry"
EMOTION_ANXIOUS = "anxious"


app = Flask(__name__)
app.config["MONGO_DBNAME"] = "primer"
mongo = PyMongo(app, config_prefix="MONGO")


@app.route("/fb_login", methods=["POST"])
def login():
    if request.method == "POST":
        if mongo.db.users.find({"_id": request.form["fb_id"]}).count() == 0:
            mongo.db.users.insert_one(
                {"_id": request.form["fb_id"], "name": request.form["name"], "join_time": datetime.now()}
            )
            return dumps({"status": "new user"})
        else:
            return dumps({"status": "existing user"})

Example #6
0
import os

from flask import Flask
from flask.ext.pymongo import PyMongo

# Where are we running?
app_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", ".."))

app = Flask(__name__)

try:
    with open(os.path.join(app_dir, "session-secret.txt"), "rt") as f:
        key = f.read()
except (IOError, OSError):
    key = "not-very-secret"
app.config["SECRET_KEY"] = key

app.config["MONGO_DBNAME"] = "docket"
mongo = PyMongo(app)

# How short do we allow names for searching?
MIN_NAME_LENGTH = 3

# How much search history should we keep?
MAX_SEARCH_HISTORY = 10
Example #7
0
File: hello.py Project: CMarth/OBET
from wtforms.validators import Required

##################
#    Config      #
##################
app = Flask(__name__)
app.config["SECRET_KEY"] = "LSKFJDSLf84wi7rleIFdso8fsL9F87SDAOIFUSOH87FS70Q03958734LKdllkjdsflskjf"

###################
#    DB Config    #
###################

app.config["MONGO_URI"] = "mongodb://mikachama:Haruka10@ds033419.mongolab.com:33419/inventory"
app.config["MONGODB_HOST"] = "ds033419.mongolab.com"
app.config["MONGODB_PORT"] = 33419
app.config["MONGO_DBNAME"] = "inventory"
app.config["MONGODB_USERNAME"] = "mikachama"
app.config["MONGODB_PASSWORD"] = "Haruka10"
app.config["ADMIN_EMAIL"] = "admin@admin.com"
app.config["ADMIN_PASS"] = "testerpassword"
app.config["MONGODB_SETTINGS"] = {
    "db": "inventory",
    "host": "mongodb://mikachama:Haruka10@ds033419.mongolab.com:33419/inventory",
}


###############
#    Init     #
###############

# Actually connects to the DB
Example #8
0
from flask import Flask, jsonify, render_template, request, jsonify, url_for, redirect
import json
from flask.ext.pymongo import PyMongo

app = Flask(__name__)
app.config["MONGO_DBNAME"] = "kirim"
mongo = PyMongo(app, config_prefix="MONGO")


@app.route("/")
def index():
    # post = {"author":"mike","text":"jiii"}
    # posts = mongo.db.posts
    # posts.insert(post)
    # posts = posts.find()
    return render_template("index.html")


@app.route("/echo/", methods=["POST"])
def echo():
    data = request.data
    print data
    data1 = json.loads(data)
    mydict = {}
    for dic in data1:
        mydict.update({dic["name"]: dic["value"]})

    mongo.db.transaksi.insert(mydict)
    varRetrun = {"msg": "succes", "code": "200"}
    varjsonReturn = json.dumps(varRetrun)
    return varjsonReturn
Example #9
0
import pprint, json, random, bson.json_util
import Queue as Q
from bson import Binary, Code

app_url = ""
app = Flask(__name__)
app.secret_key = "FF6XaS84h68MQ36j6LaHw0SQ3r8qY2YG"

from werkzeug.debug import DebuggedApplication

app.debug = True
app.wsgi_app = DebuggedApplication(app.wsgi_app, True)

app.config["MONGO_HOST"] = "ds047355.mongolab.com"
app.config["MONGO_PORT"] = "47355"
app.config["MONGO_DBNAME"] = "track-app"
app.config["MONGO_USERNAME"] = "admin"
app.config["MONGO_PASSWORD"] = "password"
mongo = PyMongo(app)


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


@app.route(app_url + "/api/cities", methods=["GET", "POST", "PUT", "DELETE"])
def cities():
    if request.method == "GET":
        return bson.json_util.dumps(mongo.db.cities.find())
    elif request.method == "POST":
Example #10
0
# Software is free software released under the "Modified BSD license"
#
# Copyright (c) 2013 Alexandre Dulaunoy - a@foo.be

from flask import Flask
from flask import render_template, url_for
from flask.ext.pymongo import PyMongo
import sys

sys.path.append("../lib/")
import cves
import redis
import pymongo

app = Flask(__name__, static_folder="static", static_url_path="/static")
app.config["MONGO_DBNAME"] = "cvedb"
mongo = PyMongo(app)


@app.route("/cve/<cveid>")
def cve(cveid):
    cvesp = cves.last(rankinglookup=True, namelookup=True, vfeedlookup=True)
    cve = cvesp.getcve(cveid=cveid)
    if cve is None:
        return page_not_found(404)
    return render_template("cve.html", cve=cve)


@app.route("/")
def last():
    cvesp = cves.last(rankinglookup=True, namelookup=True, vfeedlookup=True)
Example #11
0
from flask.ext.cors import cross_origin
from flask.ext.cache import Cache
from flask.ext.pymongo import PyMongo

# from functools import wraps
import json
import os
import pipes
import phonenumbers
import requests
from datetime import datetime, timedelta
import time
from tempfile import mkdtemp

app = Flask(__name__)
app.config["MONGO_DBNAME"] = "rushapp"
cache_dir = mkdtemp()
cache = Cache(app, config={"CACHE_TYPE": "memcached", "CACHE_MEMCACHED_SERVERS": ["127.0.0.1"]})

app = Flask(__name__)
mongo = PyMongo(app)

import logging.handlers, logging

file_handler = logging.handlers.RotatingFileHandler("/var/www/txirush.log", "a", 10000000, 1000)
file_handler.setLevel(logging.DEBUG)
file_handler.setFormatter(logging.Formatter("%(asctime)s %(levelname)s: %(message)s " "[in %(pathname)s:%(lineno)d]"))
app.logger.addHandler(file_handler)


if os.getenv("LOGFILE", None):
Example #12
0
from flask import Flask, render_template, make_response, request
from flask.ext.pymongo import PyMongo
from flask.ext.restful import Api, Resource
from bson.json_util import dumps
from bson import Code
from mongo_filter import where_from_request

app = Flask(__name__)

# register extensions
app.config["MONGO_DBNAME"] = "pyjobs"
mongo = PyMongo(app)
api = Api(app)


@app.route("/")
def hello():
    return render_template("index.html")


@app.route("/r")
def redir():
    return render_template("redirect.html")


@api.representation("application/json")
def output_json(data, code, headers=None):
    resp = make_response(dumps(data), code)
    resp.headers.extend(headers or {})
    return resp
Example #13
0
from lib.User import User
from lib.Config import Configuration
from lib.Toolkit import toStringFormattedCPE, toOldCPE, currentTime, isURL, vFeedName, convertDateToDBFormat
import lib.CVEs as cves
import lib.DatabaseLayer as db
from sbin.db_whitelist import *
from sbin.db_blacklist import *

# parse command line arguments
argparser = argparse.ArgumentParser(description="Start CVE-Search web component")
argparser.add_argument("-v", action="store_true", help="verbose output")
args = argparser.parse_args()

# variables
app = Flask(__name__, static_folder="static", static_url_path="/static")
app.config["MONGO_DBNAME"] = Configuration.getMongoDB()
app.config["SECRET_KEY"] = str(random.getrandbits(256))
pageLength = Configuration.getPageLength()

# login manager
login_manager = LoginManager()
login_manager.init_app(app)
# db connectors
redisdb = Configuration.getRedisVendorConnection()

# functions
def getBrowseList(vendor):
    result = {}
    if (vendor is None) or type(vendor) == list:
        v1 = redisdb.smembers("t:/o")
        v2 = redisdb.smembers("t:/a")
Example #14
0
# all the imports

from flask.ext.pymongo import PyMongo
from flask import Flask, request, session, g, redirect, url_for, abort, render_template, flash
import json

# configuration

DEBUG = True
SECRET_KEY = "development key"
USERNAME = "admin"
PASSWORD = "default"

# create our little application :)
app = Flask(__name__)
app.config["MONGO_DBNAME"] = "items"
mongo = PyMongo(app, config_prefix="MONGO")
app.config.from_object(__name__)
app.config.from_envvar("FLASKR_SETTINGS", silent=True)


@app.before_request
def before_request():
    pass


@app.route("/")
def show_entries():
    a = mongo.db.tblist_items.distinct("id")
    project = mongo.db.tblist_items.find()
    return render_template("index.html", entries=project)
Example #15
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
Example #16
0
from flask import Flask, Response, jsonify
from flask.ext.pymongo import PyMongo
from bson import json_util
import json

app = Flask(__name__)
app.debug = True
app.config["MONGO_DBNAME"] = "fantasywatch"
mongo = PyMongo(app)


@app.route("/players")
def index():
    players = list(
        mongo.db.players.find({}, {"season_history": 0, "fixture_history": 0, "event_eplain": 0, "fixtures": 0}).limit(
            100
        )
    )

    resp = Response(json_util.dumps(players), status=200, mimetype="application/json")

    return resp


@app.route("/players/<int:id>", methods=["GET"])
def player(id):
    player = list(mongo.db.players.find({"id": id}))

    resp = Response(json_util.dumps(player), status=200, mimetype="application/json")

    return resp
Example #17
0
import flask
from flask import request, Flask, render_template, make_response, redirect
from flask.ext.pymongo import PyMongo  # @UnresolvedImport

import sys
import os
import datetime
from babel.dates import format_timedelta
import pymongo

app = Flask(__name__)
app.config["DEBUG"] = os.environ.get("FLASK_DEBUG")


app.config["MONGO_HOST"] = os.environ.get("OPENSHIFT_MONGODB_DB_HOST", "localhost")
app.config["MONGO_DBNAME"] = os.environ.get("OPENSHIFT_APP_NAME", "testpy")
app.config["MONGO_USERNAME"] = os.environ.get("OPENSHIFT_MONGODB_DB_USERNAME")
app.config["MONGO_PASSWORD"] = os.environ.get("OPENSHIFT_MONGODB_DB_PASSWORD")

mongo = PyMongo(app)

with app.app_context():
    mongo.db.thoughts.ensure_index([("text", pymongo.TEXT)])
    mongo.db.thoughts.ensure_index([("created", pymongo.DESCENDING)])


def format_datetime(value):
    if isinstance(value, datetime.datetime):
        return value.strftime("%d-%b-%Y %H:%M")
    return value
import os
import json
from flask import Flask, Response, jsonify, render_template
from flask.ext.pymongo import PyMongo

# Initialize flask application
application = Flask(__name__, template_folder="frontend", static_folder="frontend")
application.config["MONGO_DBNAME"] = "production"
mongo = PyMongo(application)

# Determine `pwd` of this executing file
CURRENT_DIR = os.path.dirname(os.path.abspath(__file__))


@application.route("/")
def index():
    return render_template("index.html")


@application.route("/rankings")
def rankings():
    """ Return raw json from file. """
    path = os.path.join(CURRENT_DIR, "data_processing/data/current_rankings.json")
    with open(path, "r") as data:
        ranking_data = json.load(data)
    return Response(json.dumps(ranking_data), mimetype="application/json")


@application.route("/players")
def all_players():
    """ Return raw json from file. """
Example #19
0
#!/usr/bin/env python
# coding=utf-8

from flask import Flask, request, redirect, url_for, render_template
from flask.ext.pymongo import PyMongo

app = Flask(__name__)
app.config["MONGO_DBNAME"] = "mydb"
mongo = PyMongo(app)


@app.route("/")
def index():
    users = mongo.db.users.find()
    return render_template("index.html", users=users)


def valid_login(username, password):
    valid = False
    user = mongo.db.users.find({"name": username}, {"_id": 0, "name": 1, "pass": 1})
    if user:
        for u in user:
            if u["name"] == username:
                valid = True
    else:
        print "user null"
    return valid


@app.route("/login", methods=["POST", "GET"])
def login():
Example #20
0
from flask import Flask, request, jsonify, render_template
from pymongo import MongoClient

import json
import urllib2


MONGODB_HOST = "localhost"
MONGODB_PORT = 27017

app = Flask(__name__)
app.config.from_object(__name__)
app.config["MONGO_DBNAME"] = "mainAPP"

# connection = MongoClient('localhost', 27017)
connection = MongoClient(app.config["MONGODB_HOST"], app.config["MONGODB_PORT"])


@app.route("/", methods=["GET"])
def index():
    db = connection["mainAPP"]
    collection = db.urls
    urls = collection.find()
    existing_urls = []

    for url in urls:
        usr = {"url": str(url["url"])}
        existing_urls.append(usr)

    return render_template("index.html", existing=json.dumps(existing_urls))
Example #21
0
from flask import Flask, jsonify, request
from flask_jwt import JWT, jwt_required, current_identity
from werkzeug.security import safe_str_cmp
from flask.ext.pymongo import PyMongo

app = Flask(__name__)
app.debug = True
app.config["SECRET_KEY"] = "super-secret"

app.config["MONGO_HOST"] = "ds029595.mongolab.com"
app.config["MONGO_PORT"] = 29595
app.config["MONGO_DBNAME"] = "sinau"
app.config["MONGO_USERNAME"] = "sinaudb"
app.config["MONGO_PASSWORD"] = "sinaudb"
mongo = PyMongo(app, config_prefix="MONGO")


class User(object):
    def __init__(self, id, username, password):
        self.id = id
        self.username = username
        self.password = password

    def __str__(self):
        return "User(id='%s')" % self.id


users = [User(1, "user1", "abcxyz"), User(2, "user2", "abcxyz")]

username_table = {u.username: u for u in users}
userid_table = {u.id: u for u in users}
Example #22
0
# add environment variables using 'heroku config:add VARIABLE_NAME=variable_name'
DEBUG = os.environ.get("DEBUG", "True") == "True"
MONGO_URI = os.environ.get("MONGOLAB_URI")
WEBSITE_URL = os.environ.get("WEBSITE_URL", "http://localhost:5000/")

### init app ##########

app = Flask(__name__)
app.config.from_object(__name__)
app.config.from_pyfile("config.py", True)
if app.debug:
    print " * Running in debug mode"

### init database ##########

app.config["MONGO_DBNAME"] = db_name_from_uri(app.config["MONGO_URI"])
mongo = PyMongo(app)
if mongo:
    print " * Connection to database established"
else:
    raise Exception("No Mongo Connection")

### template filters ######

app.jinja_env.filters["format_date"] = string_from_datetime


### helper functions #######


def process_form(form):
Example #23
0
# -*- coding: utf-8 -*-

from flask import Flask, jsonify, url_for, redirect
from flask_pymongo import PyMongo
from flask_restful import Api, Resource
from bson.objectid import ObjectId

app = Flask(__name__)
app.config["MONGO_DBNAME"] = "boipotro_final"
mongo = PyMongo(app, config_prefix="MONGO")


class Books(Resource):
    def __init__(self):
        self.collection = mongo.db.boipotro_info_new
        self.data = []
        self.categories_in_store = []

    def get(self, category_books=None, sub_category=None, book_id=None, categories=None):
        if category_books:
            cursor = self.collection.find({"category": category_books})

            for book in cursor:
                book_id = book.pop("_id")
                book["book_id"] = str(book_id)
                self.data.append(book)

            return jsonify({"categories": category_books, "response": self.data})

        elif categories:
Example #24
0
import requests
import json
from flask import Flask, jsonify, redirect, request
from rauth import OAuth2Service
from flask.ext.pymongo import PyMongo
from bson.json_util import dumps


app = Flask(__name__)
app.config["config_prefix"] = "MONGO"
app.config["MONGO_HOST"] = "songathon.xyz"
app.config["MONGO_DBNAME"] = "users"
app.config["MONGO_PORT"] = 27017
mongo = PyMongo(app, config_prefix="MONGO")


@app.route("/api/create", methods=["POST", "GET"])
def create():
    # fb_id
    # save if it doesnt exit and return exits or not
    data = json.loads(request.data)

    blob = {
        "name": "",
        "friends": [],
        "fb_id": str(data["fb_id"]),
        "activity": {
            "curr_lat": "",
            "curr_long": "",
            "turnt_level": "",
            "activity": "",
Example #25
0
from werkzeug.datastructures import ImmutableMultiDict
import json
import bson
import requests
import collections
from ipwhois import IPWhois
import whois
import re

#################
# 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:
        network = mongo.db.network.find()
        return render_template("home.html", network=network)
    except Exception as e:
        return render_template("error.html", error=e)
Example #26
0
from flask import Flask
from flask.ext.pymongo import PyMongo
from flask.ext.restful import Api
import numpy as np

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

restapi = Api(app)

# upload image configuration
app.config["UPLOAD_FOLDER"] = "app/outputs/imgqueries/"
app.config["ALLOWED_EXTENSIONS"] = set(["txt", "pdf", "png", "jpg", "jpeg", "gif"])

# DB name configuration.
app.config["MONGO_DBNAME"] = "FoodAdvisor"
mongo = PyMongo(app, config_prefix="MONGO")

# Set app context global variable
ctx = app.app_context()
ctx.push()
current_app.mycreate = "ajlknl123j1l2k3jn123jnansfkajwe"
codebook = np.loadtxt("app/outputs/dense_codebook.txt")
tfidf = np.loadtxt("app/outputs/dense.txt")
current_app.codebook = codebook
current_app.tfidf = tfidf

from app.routes import index
from app.restapis import api

restapi.add_resource(api.UpLoad, "/api/foodimages/search")
Example #27
0
import json
import sys

sys.path.insert(0, "wrappers/")

from Users import Users as u
from Sessions import Sessions as se
from Jokes import Jokes as j

app = Flask("Crackpot")

app.config["MONGO_HOST"] = s.MONGO_HOST
app.config["MONGO_PORT"] = s.MONGO_PORT
app.config["MONGO_USERNAME"] = s.MONGO_USERNAME
app.config["MONGO_PASSWORD"] = s.MONGO_PASSWORD
app.config["MONGO_DBNAME"] = s.MONGO_DBNAME

mongo = PyMongo(app)


@app.route("/")
def index():
    try:
        if session["loggedin"] == True:
            return render_template(
                "user.html", title="Crackpot", username=session["username"], avatar_hash=get_userinfo("email_hash")
            )
        return render_template("home.html", title="Crackpot | Welcome Crackster!")
    except KeyError:
        return render_template("home.html", title="Crackpot | Welcome Crackster!")
Example #28
0
    app.config.setdefault("REDIS_DB", 0)
    app.config.setdefault("REDIS_PASSWORD", None)
    return redis.Redis(
        host=app.config["REDIS_HOST"],
        port=app.config["REDIS_PORT"],
        db=app.config["REDIS_DB"],
        password=app.config["REDIS_PASSWORD"],
    )


app = Flask(__name__, instance_relative_config=False)

app.url_map.converters["objectid"] = ObjectIDConverter


app.config["MONGO_DBNAME"] = "stalkerweb"
app.config["LOCAL_CID"] = getfqdn()
app.config["MONGO_USERNAME"] = None
app.config["MONGO_PASSWORD"] = None
app.config["GLOBAL_CLUSTERS"] = None
app.config["REMOTE_TIMEOUT"] = 2
app.config["REGISTER_KEY"] = "itsamario"
app.config["API_KEY"] = "something"
app.config["SECRET_KEY"] = "SuperSecretDevKeyChangeMe!"
app.config["THEMES"] = ["cosmo", "cerulean", "cyborg", "slate", "spacelab", "united", "flatly"]
app.config["CACHE_TTL"] = 10
app.config["GRAPHITE_ENABLE"] = False
app.config["GRAPHITE_HOST"] = "http://localhost/"
app.config["LOG_FILE"] = "/var/log/stalker/stalkerweb.log"
app.config["LOG_NAME"] = "stalkerweb"
app.config["LOG_COUNT"] = 7
Example #29
0
from flask import Flask, render_template
from flask.ext.pymongo import PyMongo

from catalog.api import APIView

app = Flask(__name__)

app.config["MONGO_DBNAME"] = "ckan"
mongo = PyMongo(app, config_prefix="MONGO")

# app.config.from_object('config')


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


@app.route("/")
def homepage():
    return render_template("index.html")


APIView.register(app, route_base="/api")
Example #30
0
from flask import Flask
from flask import make_response
from flask_restful import Resource, Api
from flask.ext.pymongo import PyMongo
from bson import json_util

app = Flask(__name__)
app.config["MONGO_DBNAME"] = "manila_routesdb"

api = Api(app)
mongo = PyMongo(app)


def get_shapes(shape_id):
    shapes = mongo.db.shapes.find({"shape_id", shape_id})
    return [shape for shape in shapes]


def get_route_trips(route_id):
    trips = mongo.db.trips.find({"route_id": route_id})
    trips_list = []

    if trips is not None:
        for trip in trips:
            if trip.get("shape_id") != "":
                trips_list.append({"trip_id": trip.get("trip_id"), "shape": trip.get("shape")})

    return trips_list


class Routes(Resource):