-
Notifications
You must be signed in to change notification settings - Fork 12
/
wallabag_mock.py
62 lines (52 loc) · 1.66 KB
/
wallabag_mock.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# -*- coding: utf-8 -*-
__author__ = 'foxmask'
import json
from flask import Flask, request
"""
The main purpose of this script is to replace v2.wallabag.org itself
just run :
python wallabag_mock.py &
and then you can launch
python wallabag_test.py
"""
app = Flask(__name__)
@app.route('/api/u/<user>/entries.json', methods=['GET'])
def get(user):
my_data = dict()
if user == 'foxmask':
my_data['entry'] = 'first content'
my_data['entry'] = 'second content'
return json.dumps(my_data,encoding='utf-8')
@app.route('/api/u/<user>/entries.json', methods=['GET'])
def get_entries(user):
my_data = dict()
if user == 'foxmask':
my_data['entry'] = 'first content'
my_data['entry'] = 'second content'
return json.dumps(my_data,encoding='utf-8')
@app.route('/api/u/<user>/entry/<int:entry>', methods=['GET'])
def get_entry(user, entry):
my_data = dict()
if user == 'foxmask' and entry == 1:
my_data['entry'] = 'third content'
return json.dumps(my_data,encoding='utf-8')
@app.route('/api/u/<user>/entries.json', methods=['POST'])
def post_entries(user):
if user == 'foxmask':
return json.dumps(True)
else:
return json.dumps(False)
@app.route('/api/u/<user>/entries.json', methods=['PATCH'])
def patch_entries(user):
if user == 'foxmask':
return json.dumps(True)
else:
return json.dumps(False)
@app.route('/api/u/<user>/entry/<int:entry>', methods=['DELETE'])
def delete_entry(user, entry):
if user == 'foxmask' and entry == 1:
return json.dumps(True)
else:
return json.dumps(False)
if __name__ == '__main__':
app.run(debug=True)