by Lazy Sloth
CodeLine Counter
import os
from flask import Flask, request, jsonify, redirect, url_for
from werkzeug.utils import secure_filename
import tempfile
import zipfile
import io
import logging
app = Flask(__name__)
logging.basicConfig(level=logging.DEBUG)
SUPPORTED_EXTENSIONS = {'py', 'html', 'js', 'jsx', 'ts', 'css', 'txt', 'json'}
# Global variable to store the results
results_data = {
'files_processed': {},
'files_skipped': [],
'total_lines': 0
}
def allowed_file(filename):
return '.' in filename and \
filename.rsplit('.', 1)[1].lower() in SUPPORTED_EXTENSIONS
CodeLine Counter
Created: | Last Updated:
Introduction to the CodeLine Counter Template
Welcome to the CodeLine Counter template! This template is designed to help you quickly set up an application that processes zip files containing code files and displays the details of each file, including the number of lines of code, in a visually appealing table format. This is an excellent tool for builders who need to analyze the volume of code in a project or for educational purposes.
Getting Started
To begin using this template, simply click on "Start with this Template" on the Lazy platform. This will pre-populate the code in the Lazy Builder interface, so you won't need to copy, paste, or delete any code manually.
Test: Deploying the App
Once you have started with the template, the next step is to deploy the app. To do this, press the "Test" button on the Lazy platform. This will initiate the deployment process and launch the Lazy CLI. The Lazy platform handles all deployment aspects, so you don't need to worry about installing libraries or setting up your environment.
Using the App
After deployment, Lazy will provide you with a dedicated server link to access the app's interface. Here's how to use the interface:
- Visit the provided server link to access the welcome page of the CodeLine Counter app.
- On the welcome page, you will see a form to upload a zip file. Click on the "Choose File" button to select the zip file containing your code files.
- After selecting the file, click on the "Upload" button to submit the file for processing.
- The app will then unzip the file, count the lines of code in each supported file, and display the results on a new page.
- You can review the number of lines of code for each file and the total lines of code processed.
Integrating the App
If you wish to integrate the CodeLine Counter app into an external service or frontend, you may need to use the server link provided by Lazy. For example, you could:
- Add the server link to an external dashboard to display code analysis results.
- Use the API endpoints provided by the app to fetch results programmatically from another application.
Remember, the CodeLine Counter app is designed to be used within the Lazy platform, and all necessary configurations are handled for you.
If you have any questions or need further assistance, feel free to reach out to the Lazy customer support team. Happy building!
Technologies
![Python](https://i.pinimg.com/originals/2f/9c/11/2f9c11f9e55efbf1791f12c06d60729b.jpg)