-
Notifications
You must be signed in to change notification settings - Fork 0
/
upgradeMe.py
executable file
·44 lines (36 loc) · 1.22 KB
/
upgradeMe.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/python3
#
# This program analyse an image containing a barcode
# au format pdf417, lit les donnees puis modifie la classe
# de de economie vers business, puis regenere un code barre.
#
# Ne pas utiliser en prod \o/
#
from plane import Plane
import sys, os
from flask import Flask, render_template, request
import pathlib
def secure_filename(name):
return name.replace(' ', '_')
app = Flask(__name__)
abs_path = str(pathlib.Path(__file__).parent.absolute()) + '/'
UPLOAD_FOLDER = 'abs_path/static/uploaded'
app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER
@app.route('/toto')
def toto_index():
return "Hello World"
@app.route('/')
def uploaded_file():
return render_template('upload.html', site_title="Upgrade this!")
@app.route('/uploader', methods = ['GET', 'POST'])
def upload_file():
if request.method == 'POST':
f = request.files['file']
imagepath = abs_path + 'static/uploaded/' + secure_filename(f.filename)
f.save(imagepath)
airbus = Plane(imagepath)
airbus.fly()
new_image_path = airbus.get_updated_filepath()
return render_template('end.html', picture_name=new_image_path)
if __name__ == '__main__':
app.run(host='0.0.0.0', port=int(os.environ['PORT']), debug = True)