Example #1
0
from google.appengine.api import users, urlfetch

from base64 import urlsafe_b64decode
from random import choice, getrandbits
from time import time
from re import sub
from os import environ

import webapp2, cgi
import requests, json, hashlib
import logging

from ath import mlab
from res import Resume

mongolab_key = str( mlab('mkey') )
tusr_db      = str( mlab('m_db') )

def Headers( headers, proc ):
  g    = str( headers )
  proc = str( proc )
  logging.info( g )
  def all():
     h = []
     for e in str( headers ).split('\n'):
       e = str( e )
       h.append(e)
     return h
  def item():
     for e in str( headers ).split('\n'):
       e = str( e )
Example #2
0
from ath import mlab
from requests import post, get, put, delete
from json import dumps
from google.appengine.api import users
from re import sub


mlusr = str(mlab("usr"))
mlpwd = str(mlab("pswd"))
mlkey = str(mlab("mkey"))
mldb = str(mlab("m_db"))
mluniq = str(mlab("muniq"))
mlport = str(mlab("mport"))
kdb = str(mlab("keydb"))

db_uri = str("mongodb://" + mlusr + ":" + mlpwd + "@" + mluniq + ".mongolab.com:" + mlport + "/" + mldb)


def pst(collection, stuff):
    if len(stuff) == 0:
        return "501"
    t = str(type(stuff))
    if not "list" in t:
        return "501"
    api = {"apiKey": mlkey}
    http_start = "https://api.mongolab.com/api/1/"
    http_type = str("databases/" + mldb + "/collections/" + collection)
    headers = {"Content-Type": "application/json"}
    try:
        r = post(http_start + http_type, params=api, headers=headers, data=dumps(stuff))
        return r.status_code