обавлен файл-заглушка для эндпоинта загрузки результатов теста (#3)#20
Open
обавлен файл-заглушка для эндпоинта загрузки результатов теста (#3)#20
Conversation
Исправление: замена бинарного файла на текстовый код
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
from flask import Flask, request, jsonify
import pandas as pd
import gspread
from oauth2client.service_account import ServiceAccountCredentials
import os
import time
app = Flask(name)
scope = ["https://spreadsheets.google.com/feeds", "https://www.googleapis.com/auth/drive"]
creds = ServiceAccountCredentials.from_json_keyfile_name('credentials.json', scope)
client = gspread.authorize(creds)
def parse_file(file_path):
if file_path.endswith('.csv'):
return pd.read_csv(file_path)
elif file_path.endswith('.xlsx'):
return pd.read_excel(file_path)
else:
raise ValueError("Неподдерживаемый формат файла")
def normalize_fio(fio):
return " ".join(str(fio).replace('\xa0', ' ').replace('\n', ' ').strip().lower().split())
def get_all_students(sheet):
students = {}
for worksheet in sheet.worksheets():
data = worksheet.get_all_values()
for real_row_idx, row in enumerate(data, start=1):
if len(row) >= 2:
if 'ф.и.о' in row[1].strip().lower():
continue
fio = row[1].strip()
fio_norm = normalize_fio(fio)
students[fio_norm] = (worksheet.title, real_row_idx)
return students
@app.route('/<sheet_id>', methods=['POST'])
def sync(sheet_id):
column_name = request.args.get('column')
grade_column = request.args.get('grade_column', column_name)
if name == 'main':
app.run(debug=True)
Closes #3