Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

working api and clean and fix porfolio empty #96

Merged
merged 13 commits into from
Sep 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -129,3 +129,4 @@ dmypy.json
.pyre/

*/raw
.vercel
16 changes: 0 additions & 16 deletions api/Pipfile

This file was deleted.

15 changes: 8 additions & 7 deletions api/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@
from fastapi.responses import HTMLResponse
from fastapi.templating import Jinja2Templates
from fastapi.security import HTTPBasic, HTTPBasicCredentials
from jose import JWTError, jwt
from datetime import datetime, timedelta
from cryptography.hazmat.primitives import asymmetric, hashes, serialization
from cryptography.hazmat.backends import default_backend
import base64
import os

# import sys
Expand All @@ -17,7 +12,9 @@

# Initialize FastAPI and Jinja2
app = FastAPI(docs_url="/docs", redoc_url=None)
templates=Jinja2Templates(directory="templates")

current_directory = os.path.dirname(os.path.abspath(__file__))
templates=Jinja2Templates(directory=os.path.join(current_directory, "templates"))

app.add_middleware(
CORSMiddleware,
Expand All @@ -38,6 +35,10 @@ async def get_current_user(credentials: HTTPBasicCredentials = Depends(security)
# Log the error here if you want
raise HTTPException(status_code=401, detail="MarketWatch validation failed")

@app.get("/")
def read_root(request: Request):
return "Marketwatch API"

@app.get("/game/{game_id}", response_class=HTMLResponse)
async def game(request: Request, game_id: str, mw: MarketWatch = Depends(get_current_user)):
data = mw.get_game(game_id=game_id)
Expand All @@ -61,4 +62,4 @@ async def card(request: Request, game_id: str, mw: MarketWatch = Depends(get_cur
@app.get("/watchlist/{watchlist_id}", response_class=HTMLResponse)
async def watchlists(request: Request, watchlist_id: str, mw: MarketWatch = Depends(get_current_user)):
data = mw.get_watchlist(watchlist_id=watchlist_id)
return templates.TemplateResponse("watchlists.html.j2", {"request": request, "data": data})
return templates.TemplateResponse("watchlists.html.j2", {"request": request, "data": data})
3 changes: 1 addition & 2 deletions api/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@ uvicorn
httpx
marketwatch
jinja2
python-jose
pydantic
marketwatch
marketwatch
21 changes: 0 additions & 21 deletions api/vercel.json

This file was deleted.

20 changes: 20 additions & 0 deletions vercel.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"version": 2,
"builds": [
{
"src": "api/app.py",
"use": "@vercel/python",
"config": {
"buildCommand": "pip install --upgrade pip && cd api && pip install -r requirements.txt && uvicorn app:app --host 0.0.0.0 --port 3000",
"debug": true
}
}
],
"routes": [
{
"src": "/(.*)",
"dest": "api/app.py"
}
]
}