This repository has been archived on 2023-06-18. You can view files and clone it, but cannot push or open issues or pull requests.
va-project/stockingly.py

31 lines
775 B
Python

from flask import Flask, jsonify, redirect, url_for, send_from_directory
from flask_cors import CORS
from backend.utils.build_frontend import build_frontend
from backend.api.companies import get_companies
import os
import subprocess
ROOT_DIR: str = os.path.dirname(__file__)
# instantiate the app
app = Flask(__name__, static_url_path='/static', static_folder='stockingly-frontend/dist')
app.config.from_object(__name__)
# enable CORS
CORS(app, resources={r'/*': {'origins': '*'}})
@app.route('/', methods=['GET'])
def index():
return redirect(url_for('static', filename='index.html'))
@app.route('/companies', methods=['GET'])
def companies() -> object:
return jsonify(get_companies(ROOT_DIR))
if __name__ == '__main__':
build_frontend()
app.run()