API for Wallabag v2 ready

This commit is contained in:
Olivier Demah
2016-04-16 16:05:15 +02:00
parent 31b6ba0d73
commit c68d065981
4 changed files with 5 additions and 126 deletions

View File

@@ -2,7 +2,7 @@
Wallabag API
============
Python API for Wallabag
Python API for Wallabag v2
Requirements :
==============
@@ -20,24 +20,9 @@ to get the project, from your virtualenv, do :
Testing :
=========
If you plan to run python wallabag_test.py, then first of all you will need to do
.. code:: python
pip install Flask
Install Wallabag V2 on your own host like explain here http://doc.wallabag.org/en/v2/user/installation.html
then
.. code:: python
python wallabag_mock.py
to start a Flask environment which will respond to all the request of the test you will start with python wallabag_test.py
Then create a client API like explain here http://doc.wallabag.org/en/v2/developer/api.html
TODO :
======
Wait the final release of http://v2.wallabag.org to be able to use the REST API (http://v2.wallabag.org/api/doc/) completly
this final release should be able to provide a token

View File

@@ -1,2 +0,0 @@
-r requirements.txt
Flask==0.10.1

View File

@@ -22,6 +22,8 @@ class Wallabag(object):
client_secret = ''
user_agent = ''
format = ''
username = ''
password = ''
def __init__(self,
host='',

View File

@@ -1,106 +0,0 @@
# -*- coding: utf-8 -*-
__author__ = 'foxmask'
import json
from flask import Flask
"""
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/entries.json', methods=['GET'])
def get_entries():
my_data = dict()
my_data['entry'] = 'first content'
my_data['entry'] = 'second content'
return json.dumps(my_data, encoding='utf-8')
@app.route('/api/entries.json', methods=['POST'])
def post_entries():
url = ''
title = ''
tags = []
return json.dumps(True)
@app.route('/api/entries/<int:entry>.json', methods=['GET'])
def get_entry(entry):
my_data = dict()
if entry == 1:
my_data['entry'] = 'third content'
return json.dumps(my_data, encoding='utf-8')
@app.route('/api/entries/<int:entry>.json', methods=['PATCH'])
def patch_entries(entry, **params):
entry = 1
params = {'title': '',
'archive': 0,
'tags': [],
'star': 0,
'delete': 0}
if entry == 1 and len(params) > 0:
return json.dumps(True)
else:
return json.dumps(False)
@app.route('/api/entries/<int:entry>.json', methods=['DELETE'])
def delete_entries(entry):
if entry == 1:
return json.dumps(True)
else:
return json.dumps(False)
@app.route('/api/entries/<int:entry>/tags.json', methods=['GET'])
def get_entry_tags(entry):
my_data = dict()
if entry == 1:
my_data = ['tag1', 'tag2', 'tag3']
return json.dumps(my_data, encoding='utf-8')
@app.route('/api/entries/<int:entry>/tags.json', methods=['POST'])
def post_entry_tags(entry, **params):
my_data = dict()
if entry == 1:
my_data = ['tag1', 'tag2', 'tag3']
return json.dumps(my_data, encoding='utf-8')
@app.route('/api/entries/<int:entry>/tags/<tag>.json', methods=['DELETE'])
def delete_entry_tag(entry, tag):
return json.dumps(entry, tag, encoding='utf-8')
@app.route('/api/tags.json', methods=['GET'])
def get_tags():
my_data = ['tag1', 'tag2', 'tag3']
return json.dumps(my_data, encoding='utf-8')
@app.route('/api/tags/<tag>.json', methods=['GET'])
def get_tag(tag):
my_data = 'tag1'
return json.dumps(my_data, encoding='utf-8')
@app.route('/api/tags/<tag>.json', methods=['DELETE'])
def delete_tag(tag):
my_data = 'tag1'
return json.dumps(my_data, encoding='utf-8')
if __name__ == '__main__':
app.run(debug=True)