<commit_before>from flask import render_template, session, redirect, url_for, flash
from .. import main
from . import get_template_data
from app import data_api_client
from flask_login import login_required, current_user
from app.main.auth import role_required
from app.api_client.errors import APIError
from app.main.forms import BaseForm
from datetime import datetime


@main.route('/service/<int:service_id>', methods=['GET'])
@login_required
def view_service(service_id):
    service = data_api_client.get_service_by_user_id_and_service_id(int(session['user_id']), service_id)
    usage = data_api_client.get_services_usage(service_id)['usage']
    today = datetime.utcnow().date()
    used_today = 0
    for use in usage:
        if use['day'] == str(today):
            used_today = use['count']

    return render_template(
        "service.html",
        form=BaseForm(),
        used_today=used_today,
        service=service['service'],
        **get_template_data())


@main.route('/service/<int:service_id>/activate', methods=['POST'])
@login_required
def activate_service(service_id):
    try:
        data_api_client.activate_service(service_id)
        flash("Service activated", "success")
        return redirect(url_for('.view_service', form=BaseForm(), service_id=service_id))
    except APIError as ex:
        flash(ex.message, "error")
        return redirect(url_for('.view_service', form=BaseForm(), service_id=service_id))


@main.route('/service/<int:service_id>/deactivate', methods=['POST'])
@login_required
def deactivate_service(service_id):
    try:
        data_api_client.deactivate_service(service_id)
        flash("Service deactivated", "success")
        return redirect(url_for('.view_service', form=BaseForm(), service_id=service_id))
    except APIError as ex:
        flash(ex.message, "error")
        return redirect(url_for('.view_service', form=BaseForm(), service_id=service_id))<commit_msg>Removed form from redirect<commit_after>from flask import render_template, session, redirect, url_for, flash
from .. import main
from . import get_template_data
from app import data_api_client
from flask_login import login_required, current_user
from app.main.auth import role_required
from app.api_client.errors import APIError
from app.main.forms import BaseForm
from datetime import datetime


@main.route('/service/<int:service_id>', methods=['GET'])
@login_required
def view_service(service_id):
    service = data_api_client.get_service_by_user_id_and_service_id(int(session['user_id']), service_id)
    usage = data_api_client.get_services_usage(service_id)['usage']
    today = datetime.utcnow().date()
    used_today = 0
    for use in usage:
        if use['day'] == str(today):
            used_today = use['count']

    return render_template(
        "service.html",
        form=BaseForm(),
        used_today=used_today,
        service=service['service'],
        **get_template_data())


@main.route('/service/<int:service_id>/activate', methods=['POST'])
@login_required
def activate_service(service_id):
    try:
        data_api_client.activate_service(service_id)
        flash("Service activated", "success")
        return redirect(url_for('.view_service', service_id=service_id))
    except APIError as ex:
        flash(ex.message, "error")
        return redirect(url_for('.view_service', service_id=service_id))


@main.route('/service/<int:service_id>/deactivate', methods=['POST'])
@login_required
def deactivate_service(service_id):
    try:
        data_api_client.deactivate_service(service_id)
        flash("Service deactivated", "success")
        return redirect(url_for('.view_service', service_id=service_id))
    except APIError as ex:
        flash(ex.message, "error")
        return redirect(url_for('.view_service', service_id=service_id))
{'fraction_non_alphanumeric': 0.11835559046870908, 'fraction_numerical': 0.0005236973029588898, 'mean_word_length': 4.5523255813953485, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '2099982', 'n_tokens_mistral': 1159, 'n_tokens_neox': 1134, 'n_words': 232}