-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #31 from edu-pi/feature/issue30
[#30] analysis 서버에서 가져온 code를 까서 까져와 결과에 담아서 반환
- Loading branch information
Showing
8 changed files
with
33 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from starlette.status import HTTP_400_BAD_REQUEST | ||
|
||
from app.web.exception.base_exception import BaseCustomException | ||
from app.web.exception.enum.error_enum import ErrorEnum | ||
|
||
|
||
class CodeVisualizeError(BaseCustomException): | ||
def __init__(self, error_enum: ErrorEnum, result: dict = None): | ||
super().__init__( | ||
status_code=HTTP_400_BAD_REQUEST, error_enum=error_enum, result={} if result is None else result | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,16 @@ | ||
import requests | ||
from app.config.settings import Settings | ||
from app.route.execute.exception.code_visualize_error import CodeVisualizeError | ||
from app.web.exception.enum.error_enum import ErrorEnum | ||
|
||
|
||
def analyze_code(source_code: str, user_input: str): | ||
visualise_url = "/".join([Settings.ENGINE_SERVER, "v1", "python"]) | ||
success_response = requests.post( | ||
response = requests.post( | ||
visualise_url, | ||
json={"source_code": source_code, "input": user_input} | ||
) | ||
return success_response | ||
if not response.ok: | ||
raise CodeVisualizeError(ErrorEnum.CODE_VISUALIZE_ERROR) | ||
|
||
return response.json().get("result").get("code") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters