-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
673ac88
commit 93c6b35
Showing
3 changed files
with
14 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
web: uvicorn run:app --host 0.0.0.0 --port $PORT | ||
web: gunicorn run:app --host 0.0.0.0 --port $PORT |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
@app.route('/') | ||
def serve(): | ||
return send_from_directory(app.static_folder, 'index.html') | ||
|
||
if __name__ == '__main__': | ||
app.run() |