36 lines
1.1 KiB
Python
36 lines
1.1 KiB
Python
from flask import Flask, jsonify, request
|
|
from flask_cors import cross_origin
|
|
|
|
app = Flask(__name__)
|
|
|
|
|
|
@app.route('/')
|
|
def hello_world(): # put application's code here
|
|
return 'Hello World!'
|
|
|
|
@app.route('/patchnotes', methods=['POST'])
|
|
def post_patchnotes():
|
|
patch_note = request.get_json()
|
|
patch_notes_db.append(patch_note)
|
|
return jsonify(patch_notes_db), 200
|
|
|
|
@app.route('/patchnotes/<string:patchID>', methods=['DELETE'])
|
|
def delete_patchnote(patchID):
|
|
global patch_notes_db
|
|
patch_notes_db = [note for note in patch_notes_db if note['patchID'] != patchID]
|
|
if any(note['patchID'] == patchID for note in patch_notes_db):
|
|
return jsonify({'error': 'Patch not deleted'}), 500
|
|
else:
|
|
return jsonify({'message': 'patch successfully deleted'}), 200
|
|
|
|
@app.route('/patchnotes/<string:date>', methods=['GET'])
|
|
def get_patchnotes(date):
|
|
unseen_notes = [note for note in patch_notes_db if note['date'] == date]
|
|
if unseen_notes:
|
|
return jsonify(unseen_notes), 200
|
|
else:
|
|
return jsonify({'error': 'no Patch notes found'}), 404
|
|
|
|
if __name__ == '__main__':
|
|
app.run()
|