Skip to content
Snippets Groups Projects
Commit 3d8ce1e0 authored by Geno Jayadi's avatar Geno Jayadi
Browse files

basic connection from frontend to backend added. Alongside minor changes to...

basic connection from frontend to backend added. Alongside minor changes to the website including user warnings
parent 248e23c3
Branches
No related tags found
No related merge requests found
from flask import Flask, render_template, url_for, request, redirect, flash from flask import Flask, render_template, url_for, request, redirect, flash
from datetime import datetime from datetime import datetime
from werkzeug.utils import secure_filename from werkzeug.utils import secure_filename
import time, os import os, time, sys
"""
The following are the import for the backend. Just write the name of the script without .py
"""
sys.path.append(os.path.join(os.path.dirname(sys.path[0]),'backend'))
import input
#define the app #define the app
app = Flask(__name__) app = Flask(__name__)
...@@ -30,14 +35,12 @@ def upload_file(): ...@@ -30,14 +35,12 @@ def upload_file():
return redirect(url_for('index')) return redirect(url_for('index'))
return redirect(url_for('case')) return redirect(url_for('case'))
@app.route('/', methods=['GET']) #login page route. eventually will be removed
#login page route
@app.route('/login.html') @app.route('/login.html')
def login(): def login():
return render_template('login.html') return render_template('login.html')
#signup page route #signup page route. eventually will be removed
@app.route('/signup.html') @app.route('/signup.html')
def signup(): def signup():
return render_template('signup.html') return render_template('signup.html')
...@@ -47,21 +50,37 @@ def signup(): ...@@ -47,21 +50,37 @@ def signup():
def case(): def case():
return render_template('case.html') return render_template('case.html')
#eventually to input the case ID selection, for now it does nothing #eventually to input the case ID, case ID is then sent to backend
@app.route('/case.html', methods=['GET']) @app.route('/case.html', methods=['POST'])
def input_caseid(): def get_caseid():
return render_template('case.html') caseid = request.form['caseId']
if caseid != '':
return redirect(url_for('recommendation',id=caseid))
else:
flash('Please input a case ID!')
return redirect(url_for('case'))
#result page route #placeholder result page route. Will eventually be removed and is now defunct.
@app.route('/result.html') @app.route('/result.html')
def result(): def result():
return render_template('result.html') return render_template('result.html')
#the actual result page route, accepts result from backend but for now it's specifically from input.py
@app.route('/result.html/<id>', methods=['GET'])
def recommendation(id):
res = input.foo(id)
return render_template('result.html',res=res)
#loading page route #loading page route
@app.route('/loading.html') @app.route('/loading.html')
def loading(): def loading():
return render_template('loading.html') return render_template('loading.html')
#about us page route
@app.route('/aboutus.html')
def aboutus():
return render_template('aboutus.html')
if __name__ == "__main__": if __name__ == "__main__":
port = int(os.environ.get('PORT', 5000)) port = int(os.environ.get('PORT', 5000))
app.run(debug=True, host='0.0.0.0', port=port) app.run(debug=True, host='0.0.0.0', port=port)
......
{% extends 'base.html' %}
{% block head %}
<title>About us</title>
{% endblock %}
{% block body %}
<div style='text-align:center'>
<h1>This is a project from the Chair of Process and Data Science from RWTH Aachen University</h1>
<img src="{{url_for('static',filename='moyai.jpg')}}" alt="Placeholder"> <br>
<h2>by: Ahmad Mannoun, Aleksandra Dimitrova, Geno Jayadi, Paula Hermenau </h2>
</div>
{% endblock %}
\ No newline at end of file
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
<noscript>Please enable javascript to use the app.</noscript> <noscript>Please enable javascript to use the app.</noscript>
<div class="topnav"> <div class="topnav">
<a href="/">Home</a> <a href="/">Home</a>
<a href="#about">About Us</a> <a href="aboutus.html">About Us</a>
<!-- <!--
<a href="login.html" class="right" style="float:right"> Login </a> <a href="login.html" class="right" style="float:right"> Login </a>
<a href="signup.html" class="right" style="float:right"> Sign Up </a> <a href="signup.html" class="right" style="float:right"> Sign Up </a>
......
...@@ -7,10 +7,10 @@ ...@@ -7,10 +7,10 @@
{%block body%} {%block body%}
<div style="text-align: center;"> <div style="text-align: center;">
<h1>Choose the case you want to optimize</h1> <h1>Choose the case you want to optimize</h1>
<form> <form method="post" id="caseid" action="{{ url_for('case')}}">
<label for="caseId"> Please enter the case ID:</label><br> <label for="caseId"> Please enter the case ID:</label><br>
<input type="text" id="caseId" name="caseId"><br> <input type="text" id="caseId" name="caseId"><br>
</form> </form>
<button onclick="window.location.href='result.html'" class="button"> Optimize now!</button> <button onclick="window.location.href='result.html'" type="submit" class="button" form="caseid" value="casevalue"> Optimize now!</button>
</div> </div>
{%endblock%} {%endblock%}
\ No newline at end of file
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
<div style="text-align: center;"> <div style="text-align: center;">
<h1>Here are the results of the optimization!</h1> <h1>Here are the results of the optimization!</h1>
<h2>We recommend you to do the following activity for this specific case:</h2> <h2>We recommend you to do the following activity for this specific case:</h2>
<h3>Placeholder</h3> <h3>Placeholder result: {{ res }}</h3>
<img src="{{url_for('static',filename='moyai.jpg')}}" alt="Placeholder"> <br> <img src="{{url_for('static',filename='moyai.jpg')}}" alt="Placeholder"> <br>
<button onclick="window.location.href='/'" class="button"> Optimize your next case NOW!</button> <button onclick="window.location.href='/'" class="button"> Optimize your next case NOW!</button>
</div> </div>
......
This diff is collapsed.
File added
import pandas as pd """
Pretend this is the backend. It simply just return it's input.
"""
#placeholder function as an example for the backend
def foo(input):
return input + " has been processed by the backend"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment