From 93c6b358885807d40e143e35c618ec8d5bcb16f2 Mon Sep 17 00:00:00 2001 From: MarkEhlerNV Date: Sat, 27 Jan 2024 10:26:18 -0500 Subject: [PATCH] update --- Procfile | 2 +- requirements.txt | Bin 868 -> 898 bytes run.py | 27 +++++++++++++-------------- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/Procfile b/Procfile index 0dfadf4..2272bbf 100644 --- a/Procfile +++ b/Procfile @@ -1 +1 @@ -web: uvicorn run:app --host 0.0.0.0 --port $PORT \ No newline at end of file +web: gunicorn run:app --host 0.0.0.0 --port $PORT \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 8d339e79e315d34bd28cb8cb396c239b83d020e3..4dde44e14184b873001da9d2e02baebee2dbafc3 100644 GIT binary patch delta 54 zcmaFD*2F&H7N;9S4nrbCF+=v`KxScCIFCV>!I>eSp$I5r3xp;NdJF~|zveRm0C+PD A#{d8T delta 39 qcmZo-f5JB5mUJ3JB117l36Lyc$YihuLIVap216iexmlPop9uiWpa_cq diff --git a/run.py b/run.py index 040a766..4a5a571 100644 --- a/run.py +++ b/run.py @@ -1,20 +1,19 @@ import time -from fastapi import FastAPI -from fastapi.middleware.cors import CORSMiddleware +from flask import Flask +from flask.helpers import send_from_directory +from flask_cors import CORS, cross_origin -app = FastAPI() -# Add CORS middleware -app.add_middleware( - CORSMiddleware, - allow_origins=["http://localhost:3000"], - allow_credentials=True, - allow_methods=["*"], - allow_headers=["*"], -) +app = Flask(__name__, static_folder='ufarms-react-client/build', static_url_path='') +CORS(app) -@app.get("/time") +@app.route('/time') +@cross_origin() def get_current_time(): return {'time': time.time()} -### note ### -# we will create all routes here until further notice \ No newline at end of file +@app.route('/') +def serve(): + return send_from_directory(app.static_folder, 'index.html') + +if __name__ == '__main__': + app.run() \ No newline at end of file