Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion API/Classes/Base/Config.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ def validate_path(base_dir, user_input):
# EXTRACT_FOLDER = Path(OSEMOSYS_ROOT, "")
# SOLVERs_FOLDER = Path(OSEMOSYS_ROOT, 'WebAPP', 'SOLVERs')

HEROKU_DEPLOY = 0
HEROKU_DEPLOY = int(os.environ.get("HEROKU_DEPLOY", 0))
API_BASE_URL = os.environ.get("API_BASE_URL", "")
AWS_SYNC = 0

PINNED_COLUMNS = ('Sc', 'Tech', 'Comm', 'Emis','Stg', 'Ts', 'MoO', 'UnitId', 'Se','Dt', 'Dtb', 'paramName','TechName', 'CommName', 'EmisName', 'ConName', 'MoId')
Expand Down
12 changes: 3 additions & 9 deletions API/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,18 +83,12 @@

CORS(app)

#potrebno kad je front end na drugom serveru 127.0.0.1
@app.after_request
def add_headers(response):
if Config.HEROKU_DEPLOY == 0:
#localhost
response.headers.add('Access-Control-Allow-Origin', 'http://127.0.0.1')
else:
#HEROKU
response.headers.add('Access-Control-Allow-Origin', 'https://osemosys.herokuapp.com/')
allowed_origin = Config.API_BASE_URL if Config.API_BASE_URL else 'http://127.0.0.1'
response.headers.add('Access-Control-Allow-Origin', allowed_origin)
response.headers.add('Access-Control-Allow-Credentials', 'true')
response.headers.add('Access-Control-Allow-Headers', 'Content-Type, Authorization')
#response.headers['Content-Type'] = 'application/javascript'
return response

# @app.errorhandler(CustomException)
Expand All @@ -114,7 +108,7 @@ def home():
# syncS3.downloadSync(case, Config.DATA_STORAGE, Config.S3_BUCKET)
# #downoload param file from S3 bucket
# syncS3.downloadSync('Parameters.json', Config.DATA_STORAGE, Config.S3_BUCKET)
return render_template('index.html')
return render_template('index.html', api_base_url=Config.API_BASE_URL)


@app.route("/getSession", methods=['GET'])
Expand Down
7 changes: 2 additions & 5 deletions WebAPP/Classes/Base.Class.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,13 @@ import { Html } from "./Html.Class.js";
import { SyncS3 } from "./SyncS3.Class.js";

export class Base {
static HEROKU = 0;
static AWS_SYNC = 0;
//init sync flag to pull from S3 only one time when visit home page
static INIT_SYNC = 1;

static apiUrl() {
if (this.HEROKU == 1) {
return "https://osemosys.herokuapp.com/";
}
return `${window.location.origin}/`;
const base = window.API_BASE_URL || window.location.origin;
return `${base}/`;
}

static initSyncS3() {
Expand Down
3 changes: 3 additions & 0 deletions WebAPP/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@
<!-- iOS web-app metas : hides Safari UI Components and Changes Status Bar Appearance -->
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">

<!-- API base URL injected by Flask; falls back to window.location.origin in Base.Class.js -->
<script>window.API_BASE_URL = "{{ api_base_url }}";</script>
</head>

<body class=" minified smart-style-4 fixed-header ">
Expand Down
Loading