|
|
@@ -7,28 +7,29 @@ app = Flask(__name__)
|
|
|
d = db()
|
|
|
|
|
|
|
|
|
-@app.route('/')
|
|
|
+BASEPATH="/pymnts"
|
|
|
+@app.route(BASEPATH+'/')
|
|
|
def index():
|
|
|
return "Hello, World!"
|
|
|
|
|
|
-@app.route('/articles/', methods=['GET'])
|
|
|
-@app.route('/articles', methods=['GET'])
|
|
|
+@app.route(BASEPATH+'/articles/', methods=['GET'])
|
|
|
+@app.route(BASEPATH+'/articles', methods=['GET'])
|
|
|
def get_articles():
|
|
|
- return jsonify({'articles': d.articles()})
|
|
|
+ return jsonify({'articles': d.articles(limit=100)}) #limit
|
|
|
|
|
|
-@app.route('/articles/<string:art_id>', methods=['GET'])
|
|
|
+@app.route(BASEPATH+'/article/<string:art_id>', methods=['GET'])
|
|
|
def get_article(art_id):
|
|
|
- art=d.articles(art_id)
|
|
|
+ art=d.articles(id=art_id)
|
|
|
if art is None:
|
|
|
abort(401)
|
|
|
return jsonify({'articles': art})
|
|
|
|
|
|
-@app.route('/sources/', methods=['GET'])
|
|
|
-@app.route('/sources', methods=['GET'])
|
|
|
+@app.route(BASEPATH+'/sources/', methods=['GET'])
|
|
|
+@app.route(BASEPATH+'/sources', methods=['GET'])
|
|
|
def get_sources():
|
|
|
return jsonify({'sources': d.sources()})
|
|
|
|
|
|
-@app.route('/sources/<string:source_id>', methods=['GET'])
|
|
|
+@app.route(BASEPATH+'/sources/<string:source_id>', methods=['GET'])
|
|
|
def get_source(source_id):
|
|
|
source=d.sources(source_id)
|
|
|
if source is None:
|
|
|
@@ -36,7 +37,7 @@ def get_source(source_id):
|
|
|
return jsonify({'source': source})
|
|
|
|
|
|
|
|
|
-@app.route('/add_source', methods=['POST'])
|
|
|
+@app.route(BASEPATH+'/add_source', methods=['POST'])
|
|
|
def create_task():
|
|
|
if not request.json or not 'title' in request.json:
|
|
|
abort(400)
|