Added file extensions
This commit is contained in:
parent
a2dc10db39
commit
a91204745e
@ -154,8 +154,9 @@ def initial():
|
|||||||
# GET method for files
|
# GET method for files
|
||||||
@app.route("/server/<lang_id>", methods=["GET"])
|
@app.route("/server/<lang_id>", methods=["GET"])
|
||||||
def file_return(lang_id):
|
def file_return(lang_id):
|
||||||
|
extensions = dict(x.split(".") for x in os.listdir("F:/Programming Projects/SmearcarDB/files"))
|
||||||
try:
|
try:
|
||||||
return send_file('files/' + lang_id)
|
return send_file('files/' + lang_id+"."+extensions[str(lang_id)])
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return str(e)
|
return str(e)
|
||||||
|
|
||||||
@ -168,7 +169,7 @@ def source_add():
|
|||||||
"password": request.form["password"]
|
"password": request.form["password"]
|
||||||
}, 2):
|
}, 2):
|
||||||
f = request.files['file']
|
f = request.files['file']
|
||||||
write_path = os.path.join(working_dir, "files", request.form['lang_id'])
|
write_path = os.path.join(working_dir, "files", request.form['lang_id']+"."+f.filename.split(".")[-1])
|
||||||
# with open(write_path, 'w') as a:
|
# with open(write_path, 'w') as a:
|
||||||
# a.write()
|
# a.write()
|
||||||
f.save(write_path)
|
f.save(write_path)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user