Lean
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Pablo Moyano 2020-07-13 02:28:11 +02:00
parent cadecba59a
commit 0b95a02778
4 changed files with 22 additions and 119 deletions

16
main.py
View File

@ -10,31 +10,21 @@ app = Flask(__name__)
app.config['UPLOAD_FOLDER'] = "./dataset/" app.config['UPLOAD_FOLDER'] = "./dataset/"
app.config['MAX_CONTENT_LENGTH'] = 10000000000 # 10GB app.config['MAX_CONTENT_LENGTH'] = 10000000000 # 10GB
meinheld.set_max_content_length(100*1024*1024)
# Return our beautiful Bootstrap webpage. That we totally have. # Return our beautiful Bootstrap webpage. That we totally have.
@app.route('/') @app.route('/')
def upload(): def upload():
return render_template('upload.html') return render_template('index.html')
# What happens when the files just don't fit
@app.errorhandler(413)
def request_entity_too_large(error):
return 'File Too Thicc', 413
# What happens when we did an oopsie
@app.errorhandler(500)
def internal_server_error(error):
return render_template('error.html')
# What happens when someone uploads a thingy # What happens when someone uploads a thingy
@app.route('/uploader', methods=['POST']) @app.route('/upload', methods=['POST'])
def upload_file(): def upload_file():
if request.method == 'POST': if request.method == 'POST':
f = request.files['file'] f = request.files['file']
# Return success webpage # Return success webpage
return render_template('successful.html') return render_template('successful.html')
else: else:

View File

@ -14,43 +14,21 @@
<link rel="stylesheet" type="text/css" href="{{ url_for('static',filename='css/normalize.css') }}" /> <link rel="stylesheet" type="text/css" href="{{ url_for('static',filename='css/normalize.css') }}" />
<link rel="stylesheet" type="text/css" href="{{ url_for('static',filename='css/main.css') }}" /> <link rel="stylesheet" type="text/css" href="{{ url_for('static',filename='css/main.css') }}" />
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous" />
integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous" />
<script src="https://code.jquery.com/jquery-3.4.1.js" <script src="https://code.jquery.com/jquery-3.4.1.js" integrity="sha256-WpOohJOqMqqyKL9FccASB9O0KwACQJpFTUBLTYOVvVU=" crossorigin="anonymous"></script>
integrity="sha256-WpOohJOqMqqyKL9FccASB9O0KwACQJpFTUBLTYOVvVU=" crossorigin="anonymous"></script> <script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script>
integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo"
crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"
integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6"
crossorigin="anonymous"></script>
<script src="{{ url_for('static',filename='js/plugins.js') }}"></script> <script src="{{ url_for('static',filename='js/plugins.js') }}"></script>
</head> </head>
<body> <body>
<!--[if IE]>
<p class="browserupgrade">
You are using an <strong>outdated</strong> browser. Please
<a href="https://browsehappy.com/">upgrade your browser</a> to improve
your experience and security.
</p>
<![endif]-->
<div class="d-flex flex-column flex-md-row align-items-center p-3 px-md-4 mb-3 bg-white border-bottom shadow-sm"> <div class="d-flex flex-column flex-md-row align-items-center p-3 px-md-4 mb-3 bg-white border-bottom shadow-sm">
<h5 class="my-0 mr-md-auto font-weight-normal">SDC Lifecycle 0.1</h5> <h5 class="my-0 mr-md-auto font-weight-normal">CSV Parser Extreme</h5>
<nav class="nav-item">
<a class="nav-link" href="https://download.med.upct.es">🗄️ Obtener Datos</a>
</nav>
</div>
<div class="alert alert-danger" role="alert">
Tool is in heavy development.
</div> </div>
{% block content %}{% endblock %} {% block content %}{% endblock %}
</body> </body>
</html> </html>

13
templates/index.html Normal file
View File

@ -0,0 +1,13 @@
{% extends "base.html" %} {% block title %}Subida{% endblock %} {% block content %}
<div class=container>
<form class="list-group list-group-flush" action="api\/upload" method="POST" enctype="multipart/form-data">
<div class="form-group">
<label for="exampleFormControlFile1">Example file input</label>
<input type="file" class="form-control-file" id="exampleFormControlFile1">
</div>
<button type="submit" class="btn btn-primary">Submit</button>
</form>
</div>
{% endblock %}

View File

@ -1,78 +0,0 @@
{% extends "base.html" %} {% block title %}Subida{% endblock %} {% block content %}
<!-- Row Header -->
<div class="px-3 py-3 pt-md-5 pb-md-4 mx-auto text-center">
<h1 class="display-4">Upload</h1>
</div>
<div class="container">
<form class="list-group list-group-flush" action="{{pagename}}/uploader" method="POST" enctype="multipart/form-data">
<!-- File input -->
<div class="list-group-item" style="padding-left: 50px;">
<input type="file" class="form-control-file" name="file" />
</div>
<!-- Sensor select -->
<div class="form-group required" style="padding-top: 10px;">
<label class="form-check-label" for="activeProbe" style="padding-left: 5px;">Escoge el sensor utilizado</label
>
<select name="activeProbe" id="activeProbe">
{% for j in i.active %}
<option value="{{ j }}">{{ j }}</option>
{% endfor %}
</select>
</div>
<!-- Force station -->
<div class="form-group">
<input
class="form-check-input"
type="checkbox"
name="forceStation{{i.sensor}}"
id="forceStation{{i.sensor}}"
onchange="toggleSelect('forceStation{{i.sensor}}', 'stations{{i.sensor}}')"
/>
<label
class="form-check-label"
for="forceStation{{i.sensor}}"
style="padding-left: 5px;"
>
Forzar estación
</label>
<label class="form-check-label" for="stations{{i.sensor}}" style="padding-left: 5px;">Selecciona la estación utilizada</label
>
<select name="stations{{i.sensor}}" id="stations{{i.sensor}}" disabled>
{% for j in i.stations %}
<option value="{{ j }}">{{ j }}</option>
{% endfor %}
</select>
</div>
<!-- Apply quality control -->
<div class="list-group-item" style="padding-bottom: 50px;">
<input
class="form-check-input"
type="checkbox"
id="autoSizingCheck"
checked
/>
<label
class="form-check-label"
for="autoSizingCheck"
style="padding-left: 5px;"
>
Aplicar control de calidad
</label>
</div>
<!-- Submit -->
<input type="hidden" value="{{i.sensor}}" name="probe" />
<button type="submit" class="btn btn-primary btn-lg btn-block">
Subir CSV
</button>
</form>
</div>
<!-- Close container field -->
{% endblock %}