class_management_system

Senior Project - Spring 2019
Log | Files | Refs | README

commit 21f9ef3f76c453f464e8d72146fd98ac8114424d
parent 24cc8a8705c333a2c5576275f9546af4b61fe260
Author: joshuajackson <joshcjack18@gmail.com>
Date:   Thu,  4 Apr 2019 13:00:27 -0400

Update main.py

Diffstat:
Msrc/python/main.py | 55+++++++++++++++++++++++++++++++++++++++++++++++++------
1 file changed, 49 insertions(+), 6 deletions(-)

diff --git a/src/python/main.py b/src/python/main.py @@ -1,14 +1,47 @@ +""" +----------------------------------------------------------------------------- + +Rowan Computer Science Dept Spring 2019 Senior Project Team +Rowan Curricular Proposal Mangagement System for Jack Myers rowan + +Senior Team Members: +Team Lead: John Kubach + Scrum Master: Joshua Jackson + Developer: Alex Kulplin + Developer: Jeffrey Podwats + Developer: Alaina Smith + Developer: Kyle Butera + +----------------------------------------------------------------------------- + +Description: + This is the code for uploading necessary images to web page + + Last edit: 4/3/19 +----------------------------------------------------------------------------- +""" + +#==========================imports=============================================== +# Imports that are need will go in this box import os import subprocess import img2pdf +#========================end===================================================== + +#=================connection===================================================== +# This will connect the back front end to the database setting flask up box from flask import Flask, request, redirect, url_for, send_from_directory, \ -render_template + render_template from flaskext.mysql import MySQL from werkzeug import secure_filename +#====================end========================================================== +#======================varibles for uploading===================================== UPLOAD_FOLDER = '/tmp/upload' ALLOWED_EXTENSIONS = set(['pdf', 'docx']) +#==========================end==================================================== +#=================================================================================== app = Flask(__name__) mysql = MySQL() app.config['MYSQL_DATABASE_USER'] = 'root' @@ -18,18 +51,25 @@ app.config['MYSQL_DATABASE_HOST'] = 'localhost' mysql.init_app(app) app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER +#===================end============================================================= +#=================Checks file to see if allowed===================================== +# def allowed_file(filename): return '.' in filename and \ filename.rsplit('.', 1)[1] in ALLOWED_EXTENSIONS +#=======================end========================================================= + +#============================================================================= +# @app.route("/", methods=['GET', 'POST']) def index(): conn = mysql.connect() - cursor =conn.cursor() + cursor = conn.cursor() if request.method == 'POST': file = request.files['file'] - doctype = request.form.get('doc_select') + doctype = request.form.get('doc_select') uname = "Kubach" if doctype == "-a": @@ -53,18 +93,20 @@ def index(): if filename.endswith('.docx'): conv = "soffice --convert-to pdf /tmp/" + filename + " --outdir " + UPLOAD_FOLDER + " --headless" subprocess.call(conv, shell=True) - cmd = "./archiver.sh -n " + uname + " -f " + filename.replace(".docx",".pdf") + " " + doctype + cmd = "./archiver.sh -n " + uname + " -f " + filename.replace(".docx", ".pdf") + " " + doctype if filename.endswith('png'): conv = "convert" + filename + " --path " + UPLOAD_FOLDER + " --headless" subprocess.call(conv, shell=True) - + newFilename = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True) cursor.execute(sql_query, newFilename.stdout.readlines()[0].strip()) conn.commit() - return redirect(url_for('index', doctype = doctype)) + return redirect(url_for('index', doctype=doctype)) return render_template('index.html') + if __name__ == "__main__": app.run(host='0.0.0.0', port=5001, debug=True) +#============================================================================= +\ No newline at end of file