Started implementing file upload
This commit is contained in:
@@ -4,7 +4,8 @@ import sqlalchemy
|
||||
from sqlalchemy.sql import select
|
||||
from sqlalchemy.sql import text
|
||||
from flask import Flask
|
||||
from flask import render_template, send_from_directory
|
||||
from flask import render_template, send_from_directory, request
|
||||
from werkzeug.utils import secure_filename
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
@@ -57,6 +58,16 @@ def getfile(filename):
|
||||
|
||||
return send_from_directory('/srv/datasheets/', 'filename')
|
||||
|
||||
@app.route('/parts/alter/<partID>', methods=['POST'])
|
||||
def alter(partID):
|
||||
'''if 'file' not in request.files:
|
||||
pass
|
||||
else:
|
||||
file = request.files['file']
|
||||
filename = secure_filename(file.filename)
|
||||
file.save(os.path.join('/srv/datasheets', filename))'''
|
||||
print dict(request)
|
||||
|
||||
def connect(user, password, db, host='localhost', port=5432):
|
||||
'''Returns a connection and a metadata object'''
|
||||
# We connect with the help of the PostgreSQL URL
|
||||
|
||||
+5
-2
@@ -94,7 +94,10 @@ function save(partID) {
|
||||
|
||||
partnos = partno_v.split(' ');
|
||||
|
||||
if (datasheet.length == 1) {
|
||||
if (datasheet.length == 0) {
|
||||
datasheet = [];
|
||||
datasheet[0] = '';
|
||||
}
|
||||
$.ajax({
|
||||
// Your server script to process the upload
|
||||
url: 'https://www.elab.kth.se/parts/alter/' + partID,
|
||||
@@ -127,7 +130,7 @@ function save(partID) {
|
||||
return xhr;
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
end_edit();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user