<commit_before>#!flask/bin/python
from flask import Flask, abort, jsonify, make_response, url_for, request
from StockIndicators.StockIndicators import *
from Authentication.Authentication import *
from flask_httpauth import HTTPBasicAuth
from datetime import datetime
import pymongo
from dbWrapper import db
from util import *


#Create application object
app = Flask(__name__)
#app.config["DEBUG"] = True
app.register_blueprint(api_stocks, url_prefix="/StockBros")

#########################
#Error control functions#
#########################
@app.errorhandler(404)
def not_found(error):
	return make_response(jsonify({'error': 'Not found'}), 404)
	
################
#      GET     #
################
@app.route('/StockBros/events', methods=['GET'])
@auth.login_required
def get_events():
	documentEvents = db.events
	events = []
	
	for event in documentEvents.find({}):
		events.append(event)
	
	return jsonify({'events': [make_public_event(e) for e in events]})

@app.route('/StockBros/events/<int:event_id>', methods=['GET'])
@auth.login_required
def get_event(event_id):
	documentEvents = db.events

	event = documentEvents.find_one({'_id':event_id})
	
	if not event:
		abort(404)

	return jsonify({'event':[make_public_event(event)]})

################
#     POST     #
################
@app.route('/StockBros/events', methods=['POST'])
@auth.login_required
#TODO COMPROBAR SE FUNCIONA CON LOGIN REQUIRED O POST
def create_event():
	if not request.json or not 'title' in request.json:
		abort(400)
	
	documentEvents = db.events
	e = documentEvents.find_one(sort=[("_id", pymongo.DESCENDING)])
	<commit_msg>elimino comentario todo porque ya está hecho<commit_after>#!flask/bin/python
from flask import Flask, abort, jsonify, make_response, url_for, request
from StockIndicators.StockIndicators import *
from Authentication.Authentication import *
from flask_httpauth import HTTPBasicAuth
from datetime import datetime
import pymongo
from dbWrapper import db
from util import *


#Create application object
app = Flask(__name__)
#app.config["DEBUG"] = True
app.register_blueprint(api_stocks, url_prefix="/StockBros")

#########################
#Error control functions#
#########################
@app.errorhandler(404)
def not_found(error):
	return make_response(jsonify({'error': 'Not found'}), 404)
	
################
#      GET     #
################
@app.route('/StockBros/events', methods=['GET'])
@auth.login_required
def get_events():
	documentEvents = db.events
	events = []
	
	for event in documentEvents.find({}):
		events.append(event)
	
	return jsonify({'events': [make_public_event(e) for e in events]})

@app.route('/StockBros/events/<int:event_id>', methods=['GET'])
@auth.login_required
def get_event(event_id):
	documentEvents = db.events

	event = documentEvents.find_one({'_id':event_id})
	
	if not event:
		abort(404)

	return jsonify({'event':[make_public_event(event)]})

################
#     POST     #
################
@app.route('/StockBros/events', methods=['POST'])
@auth.login_required
def create_event():
	if not request.json or not 'title' in request.json:
		abort(400)
	
	documentEvents = db.events
	e = documentEvents.find_one(sort=[("_id", pymongo.DESCENDING)])
	
{'fraction_non_alphanumeric': 0.19263190758663754, 'fraction_numerical': 0.007492975335622854, 'mean_word_length': 6.183856502242152, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4348084', 'n_tokens_mistral': 1064, 'n_tokens_neox': 1002, 'n_words': 233}