CarbonScript is an application that allows users to upload Python scripts, analyze the script for its contents, and calculate the CO2 emissions produced while executing the script. It also utilizes the Gemini AI model to extract insights from the Python script.
- Upload a Python file for analysis.
- Display the entire Python script in an editable text area.
- Analyze the Python script with insights provided by the Gemini AI model.
- Display the CO2 emissions calculated during the execution of the script.
-
Python 3.x
-
Install required Python libraries using
pip:pip install flask flask-cors codecarbon google-generativeai
- Sign up or log in to Google Cloud Platform.
- Go to the API & Services section and create a new project if you haven't already.
- Navigate to API & Services > Credentials.
- Click on Create Credentials and select API Key.
- Copy the generated API key.
Once you have the API key, replace the placeholder in the app.py file with your actual API key:
GOOGLE_API_KEY = 'YOUR_API_KEY_HERE'Clone the repository or navigate to your existing project folder.
Create a new virtual environment (optional but recommended):
python3 -m venv venv
Install the required Python libraries mentioned above.
Set up the Gemini API Key in the app.py file (as described above).
Run the Flask API:
python app.py
The server will run locally on http://localhost:5000.