https://github.com/asliakalin/python-interpreter
A python interpreter API for a distributed pair programming platform built for my IRB-approved thesis project in UC Berkeley.
https://github.com/asliakalin/python-interpreter
api autograder python
Last synced: 6 months ago
JSON representation
A python interpreter API for a distributed pair programming platform built for my IRB-approved thesis project in UC Berkeley.
- Host: GitHub
- URL: https://github.com/asliakalin/python-interpreter
- Owner: asliakalin
- Created: 2021-10-19T12:31:00.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2021-11-13T19:11:02.000Z (almost 4 years ago)
- Last Synced: 2025-04-11T23:48:16.800Z (6 months ago)
- Topics: api, autograder, python
- Language: Python
- Homepage:
- Size: 12.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Python Interpreter
## Intro & Motivation:
As a part of my master's program I am conducting my research on pair programming, and specifically distributed pair programming settings (where partners are paired remotely, relying on a shared code editor and a chat window while working on a task together). In order to run this study and convert it into my master's thesis, I started with creating a standalone platform for distributed pair programming that can sign new participants, create and manage pairing process, evaluate code and run autograder tests as well as collecting data from paired programing sessions.Although the source code of this project is currently stored in private repositories (at least until I finish running the study with real participants) I decided to use an API to evaluate python code that participants type in the shared editor. Here is some information about this API that is currently being hosted at http://asliakalin.pythonanywhere.com/
## A. PythonAnywhere
Here is the steps I followed while writing my own python interpreter api.
### 1. Create a new project, in the project directory:
create < api.py >
### 2. To handle http requests in python, in the terminal:
pip install requests
### 3. Go to pythonanywhere.com and create an account (can be beginner account). After sign up, go to "Open up Web App" section and make a new web app
now there is a server running at asliakalin.pythonanywhere.com, currently just displays "hello from Flask!" --> we want to change that to give us some json data
### 4. Go to source code to change the code:
Code > Source code > Go to directory > flask_app.py## B. Testing the API: Built in Debugging & Web Server for Development
- run with ```python3 api.py``` to start the debugging mode
- will show ```"Running on http://127.0.0.1:8000/"```
- in another window, run
- ```curl -v http://127.0.0.1:8000/tester``` to send a get request
- more complicated requests: ```curl -H "Content-Type: application/json" -X POST -d '{"inputs": [1,2,3], "solutions":[0,2,4], "code": "outputs=inputs*2"}' http://127.0.0.1:8000/tester```## C. A Restful API:
- flask has content type as html (not json as we'd expect from a REST API)
- use ```from flask import jsonify``` to get json data and convert content type to ```application/json```