def upload(language='python'): if language not in app.config['SUPPORTED_LANGUAGES']: abort(404) if request.method == 'POST': f = request.files['assignment'] if f and valid_file(f.filename): language_dir = os.path.join(os.getcwd(), os.path.join(app.config['UPLOAD_DIR'], language)) filename = os.path.join(language_dir, secure_filename(f.filename)) f.save(filename) with zipfile.ZipFile(filename) as zip_file: zip_file.extractall(path=language_dir) os.unlink(filename) response_url = moss.get_results(language, app.config['UPLOAD_DIR']) if 'Checking files' in response_url: return render_template('failure.html') return redirect(response_url) return render_template('failure.html') return render_template('upload.html', language=language)
def upload(language='python'): if language not in app.config['SUPPORTED_LANGUAGES']: abort(404) if request.method == 'POST': f = request.files['assignment'] if f and valid_file(f.filename): language_dir = os.path.join( os.getcwd(), os.path.join(app.config['UPLOAD_DIR'], language)) filename = os.path.join(language_dir, secure_filename(f.filename)) f.save(filename) with zipfile.ZipFile(filename) as zip_file: zip_file.extractall(path=language_dir) os.unlink(filename) response_url = moss.get_results(language, app.config['UPLOAD_DIR']) if 'Checking files' in response_url: return render_template('failure.html') return redirect(response_url) return render_template('failure.html') return render_template('upload.html', language=language)
def view(language): response_url = moss.get_results(language, app.config['UPLOAD_DIR']) return redirect(response_url)