Skip to content

Commit

Permalink
Vercel deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
cherriae committed Nov 21, 2024
1 parent 1e604f3 commit 114b45b
Show file tree
Hide file tree
Showing 10 changed files with 53 additions and 8 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,4 @@ cython_debug/
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
.vercel
6 changes: 3 additions & 3 deletions app/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import os
from dotenv import load_dotenv

from auth.auth_utils import UserManager
from app.auth.auth_utils import UserManager


mongo = PyMongo()
Expand Down Expand Up @@ -54,8 +54,8 @@ def load_user(user_id):
user_manager = UserManager(app.config["MONGO_URI"])

# Import blueprints inside create_app to avoid circular imports
from auth.routes import auth_bp
from scout.routes import scouting_bp
from app.auth.routes import auth_bp
from app.scout.routes import scouting_bp

app.register_blueprint(auth_bp, url_prefix="/auth")
app.register_blueprint(scouting_bp, url_prefix="/")
Expand Down
2 changes: 1 addition & 1 deletion app/auth/auth_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from pymongo.errors import ServerSelectionTimeoutError, ConnectionFailure
from werkzeug.security import generate_password_hash
from datetime import datetime, timezone
from models import User
from app.models import User
import logging
import time
from functools import wraps
Expand Down
2 changes: 1 addition & 1 deletion app/auth/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
flash,
)
from flask_login import login_required, login_user, current_user, logout_user
from auth.auth_utils import UserManager
from app.auth.auth_utils import UserManager
import asyncio
from functools import wraps

Expand Down
8 changes: 8 additions & 0 deletions app/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from app.app import create_app
from waitress import serve

app = create_app()

if __name__ == "__main__":
# app.run(debug=True)
serve(app, host="0.0.0.0", port=5000)
5 changes: 5 additions & 0 deletions app/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,3 +129,8 @@ def formatted_date(self):
if self.created_at:
return self.created_at.strftime("%Y-%m-%d %H:%M:%S")
return "N/A"

@property
def is_owner(self):
"""Returns whether the current user is the owner of the data"""
return str(self.scouter_id) != str(self.scouter.get("team_number"))
2 changes: 1 addition & 1 deletion app/scout/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Blueprint, flash, render_template, request, redirect, url_for, jsonify
)
from flask_login import login_required, current_user
from scout.scouting_utils import ScoutingManager
from app.scout.scouting_utils import ScoutingManager
from .TBA import TBAInterface

scouting_bp = Blueprint("scouting", __name__)
Expand Down
2 changes: 1 addition & 1 deletion app/scout/scouting_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from pymongo.errors import ServerSelectionTimeoutError, ConnectionFailure
from bson import ObjectId
from datetime import datetime, timezone
from models import TeamData
from app.models import TeamData
import logging
import time
from functools import wraps
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ Flask-Login
python-dotenv
aiohttp
pymongo
flask_pymongo
flask_pymongo
waitress
30 changes: 30 additions & 0 deletions vercel.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"version": 2,
"builds": [
{
"src": "app/main.py",
"use": "@vercel/python"
}
],
"routes": [
{
"src": "/app/static/(.*)",
"headers": {
"cache-control": "max-age=31536000, immutable"
},
"dest": "/app/static/$1"
},
{
"src": "/app/scouting/(.*)",
"dest": "app/main.py"
},
{
"src": "/app/auth/(.*)",
"dest": "app/main.py"
},
{
"src": "/(.*)",
"dest": "app/main.py"
}
]
}

0 comments on commit 114b45b

Please sign in to comment.