-
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.
Merge pull request #20 from SoleSearch-Demos/main
- Loading branch information
Showing
11 changed files
with
117 additions
and
31 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
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
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
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
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 |
---|---|---|
|
@@ -10,14 +10,16 @@ | |
load_dotenv(os.path.join(os.getcwd(), ".env")) | ||
|
||
from beanie import init_beanie | ||
from core.models.shoes import Sneaker | ||
from fastapi import FastAPI | ||
from fastapi.middleware.cors import CORSMiddleware | ||
from fastapi.openapi.docs import get_swagger_ui_html | ||
from fastapi.staticfiles import StaticFiles | ||
from mangum import Mangum | ||
from starlette.middleware.sessions import SessionMiddleware | ||
|
||
from api.data.instance import DATABASE_NAME, client | ||
from api.routes import auth, sneakers | ||
from core.models.shoes import Sneaker | ||
|
||
desc = """ | ||
### The Bloomberg Terminal of Sneakers | ||
|
@@ -27,14 +29,18 @@ | |
""" | ||
|
||
app = FastAPI( | ||
redoc_url=None, # Disable redoc, keep only swagger | ||
redoc_url=None, | ||
docs_url=None, | ||
title="SoleSearch", | ||
version=__version__, | ||
contact={"name": "SoleSearch Developer Support", "email": "[email protected]"}, | ||
contact={"name": "SoleSearch Email Support", "email": "[email protected]"}, | ||
description=desc, | ||
responses={404: {"description": "Not found"}}, # Custom 404 page | ||
) | ||
|
||
# Serve static files from the /static directory | ||
app.mount("/static", StaticFiles(directory="static"), name="static") | ||
|
||
# Enable CORS | ||
app.add_middleware( | ||
CORSMiddleware, | ||
|
@@ -43,7 +49,8 @@ | |
allow_headers=["*"], | ||
) | ||
# Enable session handling for StocxkX OAuth flow | ||
app.add_middleware(SessionMiddleware, secret_key="vT!y!r5s#bwcDxDG") | ||
SESSION_SECRET = os.environ.get("SOLESEARCH_SESSION_SECRET", "this should be a secret") | ||
app.add_middleware(SessionMiddleware, secret_key=SESSION_SECRET) | ||
|
||
|
||
@app.on_event("startup") | ||
|
@@ -58,13 +65,23 @@ async def startup_event(): | |
app.include_router(auth.router) | ||
|
||
|
||
@app.get("/docs", include_in_schema=False) | ||
async def swagger_ui_html(): | ||
return get_swagger_ui_html( | ||
openapi_url=app.openapi_url, | ||
title=app.title + " - Documentation", | ||
oauth2_redirect_url=app.swagger_ui_oauth2_redirect_url, | ||
swagger_favicon_url="/static/favicon.png", | ||
) | ||
|
||
|
||
# This is the entry point for AWS Lambda | ||
handler = Mangum(app) | ||
|
||
if __name__ == "__main__": | ||
import uvicorn | ||
|
||
# Run the app locally using Uvicorn | ||
# Run the app locally using Uvicorn, with SSL enabled | ||
uvicorn.run( | ||
app, | ||
host="localhost", | ||
|
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
Empty file.
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
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.