From 9098175f2c75f583fd3a45b44dde1cbbf38eae96 Mon Sep 17 00:00:00 2001 From: Claudio Maggioni Date: Wed, 3 May 2023 10:54:36 +0200 Subject: [PATCH] refined backend skeleton --- backend/api/.gitkeep | 0 backend/utils/build_frontend.py | 12 +++ stockingly-frontend/index.html | 2 +- .../src/components/HelloWorld.vue | 75 ------------------- .../src/layouts/default/AppBar.vue | 20 +++-- stockingly-frontend/src/plugins/vuetify.ts | 5 +- stockingly-frontend/src/views/Home.vue | 3 +- stockingly.py | 18 +++-- 8 files changed, 44 insertions(+), 91 deletions(-) create mode 100644 backend/api/.gitkeep create mode 100644 backend/utils/build_frontend.py delete mode 100644 stockingly-frontend/src/components/HelloWorld.vue diff --git a/backend/api/.gitkeep b/backend/api/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/backend/utils/build_frontend.py b/backend/utils/build_frontend.py new file mode 100644 index 0000000..63a394a --- /dev/null +++ b/backend/utils/build_frontend.py @@ -0,0 +1,12 @@ +import os +import subprocess + + +def build_frontend(): + """ + builds the frontend application + """ + + path: str = os.path.join(os.path.dirname(__file__), "..", "..", "stockingly-frontend") + p = subprocess.Popen(["yarn", "build"], cwd=path) + p.wait() \ No newline at end of file diff --git a/stockingly-frontend/index.html b/stockingly-frontend/index.html index 8943e89..f89eaa6 100644 --- a/stockingly-frontend/index.html +++ b/stockingly-frontend/index.html @@ -5,7 +5,7 @@ - Welcome to Vuetify 3 + Stockingly diff --git a/stockingly-frontend/src/components/HelloWorld.vue b/stockingly-frontend/src/components/HelloWorld.vue deleted file mode 100644 index b2573ce..0000000 --- a/stockingly-frontend/src/components/HelloWorld.vue +++ /dev/null @@ -1,75 +0,0 @@ - - - diff --git a/stockingly-frontend/src/layouts/default/AppBar.vue b/stockingly-frontend/src/layouts/default/AppBar.vue index da03149..584230c 100644 --- a/stockingly-frontend/src/layouts/default/AppBar.vue +++ b/stockingly-frontend/src/layouts/default/AppBar.vue @@ -1,13 +1,23 @@ diff --git a/stockingly-frontend/src/plugins/vuetify.ts b/stockingly-frontend/src/plugins/vuetify.ts index c276519..4e482cf 100644 --- a/stockingly-frontend/src/plugins/vuetify.ts +++ b/stockingly-frontend/src/plugins/vuetify.ts @@ -14,11 +14,12 @@ import { createVuetify } from 'vuetify' // https://vuetifyjs.com/en/introduction/why-vuetify/#feature-guides export default createVuetify({ theme: { + defaultTheme: 'light', themes: { light: { colors: { - primary: '#1867C0', - secondary: '#5CBBF6', + primary: '#009688', + secondary: '#ff4081', }, }, }, diff --git a/stockingly-frontend/src/views/Home.vue b/stockingly-frontend/src/views/Home.vue index 7646ab7..8d3d651 100644 --- a/stockingly-frontend/src/views/Home.vue +++ b/stockingly-frontend/src/views/Home.vue @@ -1,7 +1,6 @@ diff --git a/stockingly.py b/stockingly.py index 440ad99..39698a7 100644 --- a/stockingly.py +++ b/stockingly.py @@ -1,5 +1,9 @@ -from flask import Flask, jsonify, send_from_directory +from flask import Flask, jsonify, redirect, url_for, send_from_directory from flask_cors import CORS +from backend.utils.build_frontend import build_frontend +import os +import subprocess + # instantiate the app app = Flask(__name__, static_url_path='/static', static_folder='stockingly-frontend/dist') @@ -8,10 +12,12 @@ app.config.from_object(__name__) # enable CORS CORS(app, resources={r'/*': {'origins': '*'}}) -# sanity check route -@app.route('/ping', methods=['GET']) -def ping_pong(): - return jsonify('pong!') + +@app.route('/', methods=['GET']) +def index(): + return redirect(url_for('static', filename='index.html')) + if __name__ == '__main__': - app.run() \ No newline at end of file + build_frontend() + app.run()