-
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.
switched to fastapi for backend simplified requirements
- Loading branch information
1 parent
c1f884c
commit d35f1ce
Showing
4 changed files
with
16 additions
and
90 deletions.
There are no files selected for viewing
Binary file not shown.
This file was deleted.
Oops, something went wrong.
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,34 +1,20 @@ | ||
import time | ||
from flask import Flask | ||
|
||
app = Flask(__name__) | ||
|
||
@app.route('/time') | ||
from fastapi import FastAPI | ||
from fastapi.middleware.cors import CORSMiddleware | ||
|
||
app = FastAPI() | ||
# Add CORS middleware | ||
app.add_middleware( | ||
CORSMiddleware, | ||
allow_origins=["http://localhost:3000"], | ||
allow_credentials=True, | ||
allow_methods=["*"], | ||
allow_headers=["*"], | ||
) | ||
|
||
@app.get("/time") | ||
def get_current_time(): | ||
return {'time': time.time()} | ||
|
||
### note ### | ||
# we will create all routes here until further notice | ||
|
||
|
||
# ## If things are going to be like this I might shift the stack to FastAPI newer -- it's a Flask killer | ||
# Fast example of the above route using Fast | ||
|
||
# from fastapi import FastAPI | ||
# app = FastAPI() | ||
# @app.get("/") | ||
# def get_current_time(): | ||
# return {'time': time.time()} | ||
|
||
|
||
# --- | ||
## A draw back of flask is that it requires these sneaky circular-prone imports -- in my experience 90% of the time this is what's causing the error, including the one today -- I think I recall a method for addressing that | ||
# from app import app | ||
# from config import Config | ||
|
||
# app.secret_key = Config.SECRET_KEY # Set a secret key for flash messages | ||
|
||
# # if __name__ == '__main__': | ||
# # app.run(debug=True) | ||
# if __name__ == '__main__': | ||
# app.run(host='0.0.0.0', port=5000, debug=True) | ||
# we will create all routes here until further notice |
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 |
---|---|---|
|
@@ -36,5 +36,5 @@ | |
"last 1 safari version" | ||
] | ||
}, | ||
"proxy": "http://localhost:5000/" | ||
"proxy": "http://localhost:8000/" | ||
} |