From 067b12d10b3671ae1186e3eb9796c2b94ae26bbb Mon Sep 17 00:00:00 2001 From: Sasikanth L Date: Mon, 8 Jul 2024 23:10:08 +0530 Subject: [PATCH] Update port backend port --- app/prompts/python/ai_developer_django.txt | 4 +-- app/prompts/python/ai_developer_flask.txt | 4 +-- app/services/project_service.go | 2 +- .../impl/django_server_step_executor.go | 8 ++--- .../impl/flask_sever_test_executor.go | 2 +- docker-compose.yaml | 2 +- .../services/impl/docker_workspace_service.go | 2 +- .../templates/django/.vscode/tasks.json | 34 +++++++++++++++++++ .../templates/django/server_test.txt | 2 +- workspace-service/templates/flask/app.py | 2 +- 10 files changed, 48 insertions(+), 14 deletions(-) create mode 100644 workspace-service/templates/django/.vscode/tasks.json diff --git a/app/prompts/python/ai_developer_django.txt b/app/prompts/python/ai_developer_django.txt index ae7fdefe..0ff5135d 100644 --- a/app/prompts/python/ai_developer_django.txt +++ b/app/prompts/python/ai_developer_django.txt @@ -9,12 +9,12 @@ You are an expert Python and coding assistant who follows best coding practices. 6) If error is given back to you based on error update the relevant files and generate them. **INSTRUCTIONS FOR GENERATING CODE:** 1) The application is always Django-based. -2) The entry point is `manage.py`, to be executed with `python manage.py runserver 0.0.0.0:5000`. +2) The entry point is `manage.py`, to be executed with `python manage.py runserver 0.0.0.0:5001`. 3) Use SQLite for the database, with Django's built-in ORM. 4) Use Django's built-in migration system (`python manage.py makemigrations` and `python manage.py migrate`). 5) All requirements will be done using poetry. generate respective poetry add commands in `terminal.txt`. 6) Place all commands to run and test the app in `terminal.txt`. -7) Test the Django server with the designated endpoint like `http://0.0.0.0:5000` and record it in `server_test.txt`. It is important to test out all of the endpoints that are mentioned in the 'urls.py' file in the 'myapp' folder. +7) Test the Django server with the designated endpoint like `http://0.0.0.0:5001` and record it in `server_test.txt`. It is important to test out all of the endpoints that are mentioned in the 'urls.py' file in the 'myapp' folder. - In case an endpoint depends on a prexisting value such as 'company//', ensure to first add a dummy entry so as to not result in an error, then test the endpoint. 8) Maintain modular and scalable code, creating new files as needed. 9) Always include docstrings for classes, functions, and methods. diff --git a/app/prompts/python/ai_developer_flask.txt b/app/prompts/python/ai_developer_flask.txt index 59d46be0..22ae5b95 100644 --- a/app/prompts/python/ai_developer_flask.txt +++ b/app/prompts/python/ai_developer_flask.txt @@ -11,12 +11,12 @@ You have following goals, given the entire codebase and user input: INSTRUCTIONS TO FOLLOW WHILE GENERATING CODE: 1) It is a flask based application always. -2) Entry point for the application will be "app.py" only. Which has to be executed using "python app.py" and address will be "0.0.0.0" and port "5000" +2) Entry point for the application will be "app.py" only. Which has to be executed using "python app.py" and address will be "0.0.0.0" and port "5001" 3) For database use sqllite only and orm will be sqlalchemy. 4) For database migrations use alembic only - init, migrate and then upgrade. 5) All requirements will be done using poetry. generate respective poetry add commands in terminal.txt 6) All commands to start and test the app will be placed in "terminal.txt" -7) to test the flask server always create a basic endpoint like "0.0.0.0:5000/" and put in "server_test.txt" +7) to test the flask server always create a basic endpoint like "0.0.0.0:5001/" and put in "server_test.txt" 8) Keep the codebase modular and scalable by keeping relevant code in relevant files, create new files whenever needed. 9) Application will be executed using "python app.py" always. 10) Always create docstrings for classes, functions and methods. diff --git a/app/services/project_service.go b/app/services/project_service.go index 0e320e35..3427d8e7 100644 --- a/app/services/project_service.go +++ b/app/services/project_service.go @@ -82,7 +82,7 @@ func (s *ProjectService) GetProjectDetailsById(projectId int) (*models.Project, func (s *ProjectService) CreateProject(organisationID int, requestData request.CreateProjectRequest) (*models.Project, error) { hashID := s.hashIdGenerator.Generate() + "-" + uuid.New().String() url := "http://localhost:8081/?folder=/workspaces/" + hashID - backend_url := "http://localhost:5000" + backend_url := "http://localhost:5001" frontend_url := "http://localhost:3000" env := config.Get("app.env") host := config.Get("workspace.host") diff --git a/app/workflow_executors/step_executors/impl/django_server_step_executor.go b/app/workflow_executors/step_executors/impl/django_server_step_executor.go index e3d004ac..375e7d20 100644 --- a/app/workflow_executors/step_executors/impl/django_server_step_executor.go +++ b/app/workflow_executors/step_executors/impl/django_server_step_executor.go @@ -106,7 +106,7 @@ func (e DjangoServerStartTestExecutor) Execute(step steps.ServerStartTestStep) e } func (e *DjangoServerStartTestExecutor) getDjangoServerURL() string { - return "http://127.0.0.1:5000/" + return "http://127.0.0.1:5001/" } func (e *DjangoServerStartTestExecutor) getDjangoServerAppFileName() string { @@ -141,7 +141,7 @@ func (e *DjangoServerStartTestExecutor) serverRunTest(step steps.ServerStartTest } else { fmt.Println("Server process is nil, cannot kill the process.") } - e.cleanupPort(5000) + e.cleanupPort(5001) fmt.Printf("Error starting Django server: %s\n", stderr.String()) return "Failed", stderr.String() } @@ -159,7 +159,7 @@ func (e *DjangoServerStartTestExecutor) serverRunTest(step steps.ServerStartTest fmt.Println("Server process killed successfully") return "Passed", "" } else { - e.cleanupPort(5000) + e.cleanupPort(5001) return "Failed", err_msg + string(response_body) } } @@ -202,7 +202,7 @@ func RunDjangoServer(appPath string, workDir string, pythonPath string, newPath commands := []string{ fmt.Sprintf("%s %s makemigrations", pythonPath, appPath), fmt.Sprintf("%s %s migrate", pythonPath, appPath), - fmt.Sprintf("%s %s runserver 0.0.0.0:5000", pythonPath, appPath), + fmt.Sprintf("%s %s runserver 0.0.0.0:5001", pythonPath, appPath), } for i, command := range commands { diff --git a/app/workflow_executors/step_executors/impl/flask_sever_test_executor.go b/app/workflow_executors/step_executors/impl/flask_sever_test_executor.go index df74b8fe..0bbdde34 100644 --- a/app/workflow_executors/step_executors/impl/flask_sever_test_executor.go +++ b/app/workflow_executors/step_executors/impl/flask_sever_test_executor.go @@ -104,7 +104,7 @@ func (e FlaskServerStartTestExecutor) Execute(step steps.ServerStartTestStep) er } func (e *FlaskServerStartTestExecutor) getFlaskServerURL() string { - return "http://127.0.0.1:5000/" + return "http://127.0.0.1:5001/" } func (e *FlaskServerStartTestExecutor) getFlaskServerAppFileName() string { diff --git a/docker-compose.yaml b/docker-compose.yaml index cf0d0282..c5e5065a 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -171,7 +171,7 @@ services: working_dir: /workspaces ports: - 8081:8080 - - 5000:5000 + - 5001:5001 volumes: - workspaces:/workspaces diff --git a/workspace-service/app/services/impl/docker_workspace_service.go b/workspace-service/app/services/impl/docker_workspace_service.go index cd5cc5aa..de64542c 100644 --- a/workspace-service/app/services/impl/docker_workspace_service.go +++ b/workspace-service/app/services/impl/docker_workspace_service.go @@ -30,7 +30,7 @@ func (ws DockerWorkspaceService) CreateWorkspace(workspaceId string, backendTemp workspaceUrl := "http://localhost:8081/?folder=/workspaces/" + workspaceId frontendUrl := "http://localhost:3000" - backendUrl := "http://localhost:5000" + backendUrl := "http://localhost:5001" return &dto.WorkspaceDetails{ WorkspaceId: workspaceId, diff --git a/workspace-service/templates/django/.vscode/tasks.json b/workspace-service/templates/django/.vscode/tasks.json new file mode 100644 index 00000000..886bd0eb --- /dev/null +++ b/workspace-service/templates/django/.vscode/tasks.json @@ -0,0 +1,34 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "Run Python App", + "type": "shell", + "command": "(ps -ef | grep 'python3 manage.py runserver 0.0.0.0:5001' | grep -v grep | awk '{print $2}' | xargs -r kill -9 || true) && python3 manage.py runserver 0.0.0.0:5001", + "options": { + "shell": { + "executable": "/bin/bash", + "args": [ + "-c" + ] + } + }, + "isBackground": false, + "problemMatcher": [], + "group": { + "kind": "build", + "isDefault": true + }, + "presentation": { + "echo": true, + "reveal": "always", + "focus": false, + "panel": "dedicated", + "showReuseMessage": true + }, + "runOptions": { + "runOn": "folderOpen" + } + } + ] + } \ No newline at end of file diff --git a/workspace-service/templates/django/server_test.txt b/workspace-service/templates/django/server_test.txt index ef6cc63a..4ca2ed70 100644 --- a/workspace-service/templates/django/server_test.txt +++ b/workspace-service/templates/django/server_test.txt @@ -1 +1 @@ -http://0.0.0.0:5000 \ No newline at end of file +http://0.0.0.0:5001 \ No newline at end of file diff --git a/workspace-service/templates/flask/app.py b/workspace-service/templates/flask/app.py index e374bb0f..93ea89e8 100644 --- a/workspace-service/templates/flask/app.py +++ b/workspace-service/templates/flask/app.py @@ -39,4 +39,4 @@ # Run the application if __name__ == '__main__': - app.run(host='0.0.0.0', port=5000, debug=True) \ No newline at end of file + app.run(host='0.0.0.0', port=5001, debug=True) \ No newline at end of file