Skip to content

Commit

Permalink
backend comments and clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
rbs333 committed Apr 30, 2019
1 parent 91900c3 commit f4831c3
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 7 deletions.
Empty file.
9 changes: 9 additions & 0 deletions algorithm/tsp.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@
Created on Sat Jun 30 21:01:11 2018
@author: Fangzhou Sun
This file is intended to show an example of how Gurobipy can be used
to create optimization algorithms in an object oriented way. In structure,
it is very similar to s_bfl.py and should be a starting point for writing
additional optimizations. Writting optimizations in an object oriented way
makes it much easier to utilize the code within a project because we can
simply import the class into another python file and create an instance of
the class to run the optimization.
"""
import numpy as np
from scipy.spatial import distance_matrix
Expand Down
8 changes: 7 additions & 1 deletion frontend/src/components/S_BFLS.vue
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,13 @@ export default {
this.model.input_format = mapInfo.mode;
this.model.refinery_location = mapInfo.refinery_location;
this.model.new_input = this.new_input;
console.log(this.model);
/*
axios is a 3rd party module that allows us to communicate with the backend API.
In this case, we issue a post method and provide axios the port our server is running
on (http://localhost:5000) with the route we want to access (/s-bfls/) plus the data we
want to send it (this.model). We then instruct axios what to do onec it gets a response
from the backend server sends in the .then() section.
*/
axios
.post('http://localhost:5000/s-bfls/', this.model)
.then(response => {
Expand Down
68 changes: 68 additions & 0 deletions frontend/src/components/Template.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<template>
<div>
<!-- This is where html gets written -->
<div class="title">This is a Vue Template File</div>

<!--
Here we use the ListInput component written in
another part of our code. We use v-bind to bind a value
from the data section to the list prop in the the ListInput
component. We then use v-on to tell the ListInput to bind
to userInput whenever the input is changed. After, that we use
v-bind twice more to pass data into the component.
-->
<ListInput
v-bind:list='list'
v-on:listChange='userInput = $event'
v-bind:label="'Example List Input'"
v-bind:tooltips='exampleTooltips'
></ListInput>
</div>
</template>

<script>
import ListInput from './ListInput'
export default {
// props are objects that you can pass into a child element
// Template.vue would be a child of whatever component it is imported into
props: {
model: {
type: Object
}
},
// Components are other .vue files that can be added to your code so that you don't
// have to write the same code twice. You import components at the time of the file
// and register them here.
components: {
'ListInput': ListInput,
},
// Methods are functions you want to be able to access from the template section
// the allow us to execute commands with data.
methods: {
emit() {
this.$emit('formChange', this.model)
}
},
// data is where declare the variables that you want your code to use
// and interact with
data() {
return {
list: ["example", "example", "example"],
// update list will get stored in this variable
userInput: [],
exampleTooltips: ["this is 1", "this is 2", "this is 3"]
}
}
}
</script>

<style>
/*
this is where css is written. However, try as much as possible not to write
your own css because we are using Bulma as our primary style framework. If you don't
known what that is google "Bulma css" - I'm not your mom. Hopefully mystyles.css
still exists at this point.
*/
</style>
16 changes: 10 additions & 6 deletions myapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,16 @@
from flask import Flask, render_template, request, send_from_directory, jsonify, send_file
from algorithm.tsp import tsp
from algorithm.s_bfl import s_bfl
# from email_credentials import credentials
# from flask_mail import Mail
# from flask_mail import Message
from flask_cors import CORS, cross_origin
# from simulation.sim import Simulation
from algorithm.geo import Geo
from simulation.sim import Simulation
import json

""" for email feature
# from email_credentials import credentials
# from flask_mail import Mail
# from flask_mail import Message
"""
class CustomFlask(Flask):
jinja_options = Flask.jinja_options.copy()
jinja_options.update(dict(
Expand All @@ -31,10 +32,10 @@ class CustomFlask(Flask):
app = CustomFlask(__name__) # This replaces your existing "app = Flask(__name__)"
CORS(app, supports_credentials = True)

""" for email feature
# c = credentials()
# c.setPassword()

# app.config.update(
# DEBUG = True,
# MAIL_SERVER = 'smtp.gmail.com',
Expand All @@ -45,7 +46,7 @@ class CustomFlask(Flask):
# )
# mail = Mail(app)

"""
my_sim = Simulation()

@app.route('/s-bfls/', methods=['POST'])
Expand All @@ -62,13 +63,16 @@ def Sbfl():
my_sim.main()
response_dict['sim_response'] = my_sim.sim_results
response = jsonify(response_dict)

""" for email feature
# response.headers.add('Access-Control-Allow-Origin', '*')
# msg = Message('S-BFLS',
# sender="[email protected]",
# recipients=["[email protected]"])
# msg.body = "Thanks for using SBFLS! Attached are our results."
# mail.send(msg)
"""
return response

@app.errorhandler(404)
Expand Down

0 comments on commit f4831c3

Please sign in to comment.