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

Refactor(Server): Combine main.py and server.py #148

Closed
wants to merge 6 commits into from
Closed
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
2 changes: 2 additions & 0 deletions config/.env.local
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
SERVER_HOST=localhost
SERVER_PORT=8000
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
"scripts": {
"check:all": "npm run lint:all && npm run test:all && npm run build:client",
"install:all": "npm run create:venv && npm run install:forge && npm run install:server && npm run install:client",
"start:all": "chmod +x scripts/start:all.sh && scripts/start:all.sh",
"start:all": "chmod +x scripts/start:all.sh && scripts/start:all.sh && cd server && . .venv/bin/activate && python3 main.py",
"test:all": "npm run test:client && npm run test:server && npm run acceptance:run",
"stop:all": "chmod +x scripts/stop:all.sh && scripts/stop:all.sh",
"freeze:all": "npm run freeze:forge && npm run freeze:server",
"start:client": "cd client && npm start",
"start:server": "cd server && . .venv/bin/activate && python3 server.py",
"start:server": "cd server && . .venv/bin/activate && python3 main.py",
"acceptance:run": "chmod +x scripts/acceptance:run.sh && scripts/acceptance:run.sh",
"acceptance:open": "chmod +x scripts/acceptance:open.sh && scripts/acceptance:open.sh",
"test:client": "cd client && npm test",
Expand All @@ -28,4 +28,4 @@
"freeze:server": "cd server && . .venv/bin/activate && pip3 freeze > requirements.txt && deactivate",
"freeze:forge": "cd forge && . .venv/bin/activate && pip3 freeze > requirements.txt && deactivate"
}
}
}
7 changes: 7 additions & 0 deletions scripts/start
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

# Start the client
cd client && npm start &

# Start the server
cd server && . .venv/bin/activate && python3 main.py &
10 changes: 10 additions & 0 deletions server/main.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
from fastapi import FastAPI
from transformers import logging
from dotenv import load_dotenv
from uvicorn import run
import os

from src.controllers.ForgeController import ForgeController

app = FastAPI()

logging.set_verbosity_error()

load_dotenv("../config/.env.local")

host = os.getenv("SERVER_HOST")
port = int(os.getenv("SERVER_PORT"))


@app.get("/")
def welcome():
Expand All @@ -22,3 +30,5 @@ def welcome():
forge_routes = ForgeController().get_router()

app.include_router(forge_routes)

run("main:app", host=host, port=port)
2 changes: 1 addition & 1 deletion server/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,4 @@ uvicorn==0.23.1
wcwidth==0.2.6
Werkzeug==2.3.6
widgetsnbextension==4.0.8
wrapt==1.15.0
wrapt==1.15.0