Esempio n. 1
0
File: views.py Progetto: cbrem/prwl
def login():
	username = request.params.username
	password = request.params.password
	user = User.get({'username': username})
	if user and check_password_hash(user.hash, password):
		login_user(user)
		return json({})
	else:
		abort(403)
Esempio n. 2
0
File: views.py Progetto: cbrem/prwl
def create_user():
	username, password = request.json.username, request.json.password
	if not User.get({'username': username}):
		user = User.create({
			'username': username,
			'hash': generate_password_hash(password)
		})
		login_user(user)
		return json({'username': username})
	else:
		abort(403)
Esempio n. 3
0
File: views.py Progetto: cbrem/prwl
def logout():
	logout_user()
	return json({})
Esempio n. 4
0
File: views.py Progetto: cbrem/prwl
def get_user(username):
	user = User.get({'username': username})
	return json(user.dict())
Esempio n. 5
0
File: views.py Progetto: cbrem/prwl
def get_pin(_id):
	pin = Pin.get(_id)
	return json(pin)
Esempio n. 6
0
File: views.py Progetto: cbrem/prwl
def get_pins():
	filter = request.params
	pins = Pin.get_many(filter)
	return json({'pins': [pin.dict() for pin in pins]})
Esempio n. 7
0
File: views.py Progetto: cbrem/prwl
def delete_pin(_id):
	Pin.delete({'_id': _id})
	return json({})
Esempio n. 8
0
File: views.py Progetto: cbrem/prwl
def update_pin(_id):
	Pin.update({'_id': _id}, request.json)
	return json({})
Esempio n. 9
0
File: views.py Progetto: cbrem/prwl
def create_pin():
	pin = Pin.create(request.json)
	return json({'_id': pin._id})
Esempio n. 10
0
    parameter1 = sys.argv[1]
except IndexError:
    parameter1 = 'backup'

# oauth检查设置
import get_token
get_token.oauth2()

import time
time = time.strftime("%Y-%m-%d %H:%M:%S")
filename = "backup"+time

if parameter1 == 'backup':
    baseUrl = 'http://api.fanfou.com/statuses/user_timeline'
    page=1
    import util
    #python没有switch语句,所以只能用if语句替代了。
    if parameter2 == 'xml':
        util.xml(page, url=baseUrl+'.xml', filename=filename+'.xml')
        print '备份文件backup'+time+'.xml成功!'
    elif parameter2 == 'json':
        util.json(page, url=baseUrl+'.json', filename=filename+'.json')
        print '备份文件backup'+time+'.json成功!'
    else:
        print '不知道备份成什么格式'
    


    

Esempio n. 11
0
try:
    parameter2 = sys.argv[2]
except IndexError:
    parameter2 = 'xml'
try:
    parameter1 = sys.argv[1]
except IndexError:
    parameter1 = 'backup'

# oauth检查设置
import get_token
get_token.oauth2()

import time
time = time.strftime("%Y-%m-%d %H:%M:%S")
filename = "backup" + time

if parameter1 == 'backup':
    baseUrl = 'http://api.fanfou.com/statuses/user_timeline'
    page = 1
    import util
    #python没有switch语句,所以只能用if语句替代了。
    if parameter2 == 'xml':
        util.xml(page, url=baseUrl + '.xml', filename=filename + '.xml')
        print '备份文件backup' + time + '.xml成功!'
    elif parameter2 == 'json':
        util.json(page, url=baseUrl + '.json', filename=filename + '.json')
        print '备份文件backup' + time + '.json成功!'
    else:
        print '不知道备份成什么格式'