Skip to content

Commit

Permalink
Updating Pathing and Ports
Browse files Browse the repository at this point in the history
  • Loading branch information
TheManWhoLikesToCode committed Jan 12, 2024
1 parent 0080ebb commit ed59247
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 8 deletions.
11 changes: 10 additions & 1 deletion backend/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,16 @@ def clean_up_and_upload_files_to_google_drive(file_path=None):


def authorize_drive():
with open('settings.yaml', 'r') as file:
current_directory = os.getcwd()

if 'backend' in current_directory:
settings_path = 'settings.yaml'
elif 'Archive-Me' in current_directory:
settings_path = 'backend/settings.yaml'
else:
raise Exception("Unable to locate settings file.")

with open(settings_path, 'r') as file:
settings = yaml.safe_load(file)

settings['client_config']['client_id'] = os.environ.get('GOOGLE_CLIENT_ID')
Expand Down
7 changes: 1 addition & 6 deletions frontend/app.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from flask import Flask, render_template, request, jsonify, send_from_directory, abort
from flask import Flask, render_template
from flask_cors import CORS, cross_origin
import os
import logging
Expand Down Expand Up @@ -28,11 +28,6 @@ def demo():
def directory():
return render_template('directory.html')

# Add a login route for demonstration
@app.route('/login', methods=['POST'])
def login():
# Your login logic here
return jsonify(success=True)

if __name__ == '__main__':
app.run(host='0.0.0.0', port=app.config['PORT'], debug=app.config['DEBUG'])
6 changes: 6 additions & 0 deletions frontend/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"apiUrl":{
"dev":"http://localhost:5003",
"prod":"https://api.archive-me.net"
}
}
14 changes: 14 additions & 0 deletions frontend/static/helpers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import config from 'frontend/config.json'

function getEnv() {
if (!process.env) {
throw new Error('Process environment not found.');
}
return process.env.ENVIRONMENT
}

function getApiUrl() {
return config.apiUrl[getEnv()]
}

export { getEnv, getApiUrl }
5 changes: 4 additions & 1 deletion frontend/static/scripts.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { getApiUrl } from "./helpers";

$(function () {
// init feather icons
feather.replace();
Expand Down Expand Up @@ -83,7 +85,8 @@ $(function () {
const app = (() => {
let fileKeyGlobal = null;
let currentPath = '';
const apiUrl = 'https://api.archive-me.net';

const apiUrl = getApiUrl();

const showLoadingScreen = () => {
const loadingScreen = document.getElementById("loading-screen");
Expand Down

0 comments on commit ed59247

Please sign in to comment.