Skip to content

Commit b33fe18

Browse files
committed
Set up branch
1 parent fb09b02 commit b33fe18

File tree

5 files changed

+56
-0
lines changed

5 files changed

+56
-0
lines changed

matching-service/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.venv
2+
app/__pycache__
3+
app/routers/__pycache__

matching-service/README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Dependencies: Python 12
2+
3+
## Setup
4+
1. In the `matching-service` directory, run `python -m venv .venv` to create a virtual environment.
5+
2. Run `source .venv/bin/activate` for mac or `.\.venv\Scripts\activate` for windows to activate the virtual environment.
6+
3. Run `pip install -r requirements.txt` to install all necessary dependencies.
7+
4. Ensure you have a `.env` file in `matching-service` with the question service mongoDB uri.
8+
5. To start the service, run `fastapi dev app/main.py`
9+
10+
Note: For VSCode to properly detect the venv, open the project with `matching-service` as the root directory. If not, VSCode will not detect the venv properly and will scream at you for everything.

matching-service/app/main.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
from fastapi import FastAPI
2+
from fastapi.middleware.cors import CORSMiddleware
3+
import os
4+
5+
# from routers import questions
6+
from routers import match
7+
8+
app = FastAPI(title="Matching Service API")
9+
10+
origins = [
11+
"http://localhost:3000",
12+
]
13+
14+
app.add_middleware(
15+
CORSMiddleware,
16+
allow_origins=origins,
17+
allow_credentials=True,
18+
allow_methods=["*"],
19+
allow_headers=["*"],
20+
)
21+
22+
# Include routers
23+
app.include_router(match.router, prefix="/match", tags=["match"])
24+
25+
if __name__ == "__main__":
26+
import uvicorn
27+
28+
uvicorn.run(
29+
"main:app",
30+
host="0.0.0.0",
31+
port=int(os.environ.get("PORT", 8000)),
32+
reload=(os.environ.get("BUILD_ENV", "dev") == "dev")
33+
)
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
from fastapi import APIRouter, HTTPException
2+
# from models.questions import CreateQuestionModel, UpdateQuestionModel, QuestionModel, QuestionCollection, MessageModel
3+
from typing import List
4+
5+
router = APIRouter()
6+
7+
# Make a dummy endpoint to test the connection
8+
@router.get("/")
9+
async def test_connection():
10+
return {"message": "Connection successful"}

matching-service/requirements.txt

1.18 KB
Binary file not shown.

0 commit comments

Comments
 (0)