https://github.com/rahul-shrivastav/python-code-execution-server
An API created with Flask to compile and execute python code .
https://github.com/rahul-shrivastav/python-code-execution-server
flask flask-api python
Last synced: 2 months ago
JSON representation
An API created with Flask to compile and execute python code .
- Host: GitHub
- URL: https://github.com/rahul-shrivastav/python-code-execution-server
- Owner: rahul-shrivastav
- Created: 2025-01-06T22:33:36.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-02-27T17:45:53.000Z (over 1 year ago)
- Last Synced: 2025-04-06T08:31:25.903Z (about 1 year ago)
- Topics: flask, flask-api, python
- Language: Python
- Homepage:
- Size: 28.3 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# Python Code Execution API


This is a Python Code Execution API built with Flask that allows users to execute Python code in a secure and isolated environment. It provides an API for submitting Python code, running it, and retrieving the output. This can be integrated into platforms that need code execution features, like coding challenge platforms, learning tools, or testing environments.
## Features
Execute Python Code: Submit Python code via API, and get execution results.
Secure Execution: Code is executed in a controlled environment to prevent security risks.
Support for Python 3.x: The API uses Python 3.x for code execution.
Timeout Handling: Limits execution time to prevent infinite loops or long-running code.
## Tech Stack
- ` Python ` : versatile, high-level, interpreted, easy-to-learn programming language.
- ` Flask `: A lightweight Python web framework to build APIs.
- ` Subprocess `: Used to run Python code in a separate process.
- ` Timeouts ` : To prevent long or malicious code from running indefinitely.
## Prerequisites
Before getting started, make sure you have the following installed:
- Python 3.x
- pip (Python package manager)
# Setup Instructions
### 1. Clone the Repository
First, clone the repository to your local machine:
```bash
git clone https://github.com/rahul-shrivastav/Python-Code-Execution-Server.git
```
### 2. Install Dependencies
Install the required Python dependencies by running:
```bash
pip install -r requirements.txt
```
### 3. Running the Flask Server
To start the Flask server locally, run:
```bash
python app.py
```
This will start the server on port `5000` locally.
## API Reference
#### Execute the code
```http
POST /execute
```
| Parameter | Type | Description |
| :-------- | :------- | :------------------------- |
| `code` | `string` | Code provided by the user to execute. |