project_root
│
├── src
│ ├── list_languages.py
│ └── main.py
│
├── bin
│ └── logfile.log
│
├── input
│ ├── language_list.txt
│ ├── code.txt
│ └── input.txt
│
├── .env
├── requirements.txt
└── README.md
This project is a code execution tool that interacts with an online code compiler API. It consists of the following folders and files:
- src: Contains the main Python scripts.
list_languages.py
: Retrieves and prints a list of available programming languages from the online code compiler API based on the contents oflanguage_list.txt
in theinput
folder.main.py
: Prompts the user for a programming language, checks its availability using the API, and then executes the code fromcode.txt
in theinput
folder with corresponding input frominput.txt
. The output is stored inoutput.txt
in thebin
folder.
- bin: Stores the output of code execution (
output.txt
) and logs (logfile.log
). - input: Contains input files for code (
code.txt
andinput.txt
) and a list of languages (language_list.txt
). - .env: Environment configuration file.
- requirements.txt: Specifies the project's dependencies. Developers can install these dependencies using the
pip install -r requirements.txt
command to ensure a consistent environment. - README.md: Documentation file.
- .gitignore: Ignored files and directories for version control.
- LICENSE: License information for the project.
- Use the following command to install dependencies:
pip install -r requirements.txt
- Set the following environment variables in the
.env
file. You can get these details by subscribing to - Online Code Compiler
- `API_KEY`: Your API key for authentication.
- `HOST` : Host for the online compiler. [online-code-compiler.p.rapidapi.com]
- `LANGUAGE_LIST_URL` : API base URL to GET Languages. [https://online-code-compiler.p.rapidapi.com/v1/languages/]
- `COMPILE_CODE_URL` : API base URL to POST Request on online code compiler to execute the code. [https://online-code-compiler.p.rapidapi.com/v1/]
-
Execute the
list_languages.py
script to retrieve and display the list of available programming languages. The information is sourced from thelanguage_list.txt
file located in theinput
directory. Note that this file is pre-populated for reference, and user don't need to run this script.python src/list_languages.py
-
Execute the
main.py
script to run user-specified code. The script will prompt the user for a programming language input. It will then perform the following steps:- Check if the specified language exists using the
get_language
API call. - Verify the presence of the
code.txt
file in theinput
directory, containing the code to be executed. - Check for the existence of the
input.txt
file in theinput
directory for providing input to the code. - If all checks pass, the script will execute the code and return the output, which will be recorded in
output.txt
in thebin
directory. - Logs for all operations will be generated and recorded in
logfile.log
in thebin
directory.
python src/main.py
- Check if the specified language exists using the
This project is licensed under the MIT License - see the LICENSE file for details.