Skip to content

Commit

Permalink
Merge branch 'main' of github.com:HackAtUCI/irvinehacks-site-2024 int…
Browse files Browse the repository at this point in the history
…o setup/about
  • Loading branch information
samderanova committed Nov 24, 2023
2 parents 03c83ec + 721bac3 commit 9863009
Show file tree
Hide file tree
Showing 31 changed files with 683 additions and 4,807 deletions.
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
PYTHONPATH=apps/api/src
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,6 @@ yarn-error.log*

# vercel
.vercel

# Python
.venv
12 changes: 7 additions & 5 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
{
"eslint.workingDirectories": [
{
"mode": "auto"
}
]
"eslint.workingDirectories": [
{
"mode": "auto"
}
],
"python.envFile": "${workspaceFolder}/.env",
"python.defaultInterpreterPath": ".venv/bin/python",
}
1 change: 1 addition & 0 deletions apps/api/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__pycache__
19 changes: 19 additions & 0 deletions apps/api/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# IrvineHacks Site API

This "app" contains the source code for the backend API used by the site.

## Local Development

For local development, run

```shell
python src/dev.py
```

which will start a Uvicorn server with auto-reload.

## Deployment Configuration

For deployment, the following environment variables need to be set:

- `PYTHONPATH=src/api` to properly import Python modules
12 changes: 12 additions & 0 deletions apps/api/index.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import logging

from fastapi import FastAPI

from app import app as api

# Override AWS Lambda logging configuration
logging.basicConfig(level=logging.INFO, force=True)

# This ASGI app is used by Vercel as a Serverless Function
app = FastAPI()
app.mount("/api", api)
7 changes: 7 additions & 0 deletions apps/api/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "api",
"private": true,
"scripts": {
"dev": "python src/dev.py"
}
}
1 change: 1 addition & 0 deletions apps/api/requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
uvicorn[standard]==0.23.2
1 change: 1 addition & 0 deletions apps/api/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fastapi==0.104.1
8 changes: 8 additions & 0 deletions apps/api/src/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from fastapi import FastAPI

app = FastAPI()


@app.get("/")
async def root() -> dict[str, str]:
return {"message": "hello"}
10 changes: 10 additions & 0 deletions apps/api/src/dev.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import uvicorn

if __name__ == "__main__":
uvicorn.run(
"app:app",
log_level="info",
access_log=True,
use_colors=True,
reload=True,
)
5 changes: 5 additions & 0 deletions apps/site/api/index.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
"""
This is an empty source file necessary for Vercel to recognize the existence of
the Serverless Function for the backend API as defined in `vercel.json`.
The contents will be replaced by that of `apps/api/index.py` during Turbo build.
"""
4 changes: 4 additions & 0 deletions apps/site/copy-api.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copy API files from apps/api
cp -R ../api/requirements.txt .
cp -R ../api/src/ src/api/
cp ../api/index.py api/index.py
Loading

0 comments on commit 9863009

Please sign in to comment.