Skip to content

Lightweight web-based file manager built in TCL using the wapp framework. Browse directories and view files through a simple web interface.

License

Notifications You must be signed in to change notification settings

gajeshbhat/TCL-Web-File-Manager

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

8 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

TCL Web File Manager

A lightweight, web-based file manager built in TCL using the wapp framework. Browse directories, view files, and navigate your filesystem through a simple web interface.

Features

  • πŸ“ Browse directories and files through a web interface
  • πŸ“„ View file contents directly in the browser
  • πŸ”— Navigate through directories with clickable links
  • πŸš€ Lightweight and fast - built with pure TCL
  • 🌐 Accessible from any web browser
  • πŸ“± Simple, responsive HTML interface

Prerequisites

System Requirements

  • TCL 8.6+ (tested with TCL 8.6.14)
  • tcllib package (provides fileutil utilities)
  • Unix-like system (Linux, macOS, WSL)

Installation

Ubuntu/Debian

sudo apt update
sudo apt install tcl tcllib

CentOS/RHEL/Fedora

# CentOS/RHEL
sudo yum install tcl tcllib

# Fedora
sudo dnf install tcl tcllib

macOS (with Homebrew)

brew install tcl-tk
# tcllib is usually included with tcl-tk on macOS

Arch Linux

sudo pacman -S tcl tcllib

Quick Start

  1. Clone the repository:

    git clone https://github.com/yourusername/TCL-Web-File-Manager.git
    cd TCL-Web-File-Manager
  2. Make the run script executable:

    chmod +x run_server.sh
  3. Start the server:

    ./run_server.sh

    Or manually:

    tclsh file_manager.tcl --server 8080
  4. Open your browser: Navigate to http://localhost:8080

Usage

Starting the Server

The server starts on port 8080 by default. You can specify a different port:

tclsh file_manager.tcl --server 3000

Navigation

  • Click on directory names (ending with /) to browse into subdirectories
  • Click on file names to view file contents
  • The server starts browsing from the current working directory

Stopping the Server

Press Ctrl+C in the terminal where the server is running.

Project Structure

TCL-Web-File-Manager/
β”œβ”€β”€ file_manager.tcl      # Main application file
β”œβ”€β”€ run_server.sh         # Convenience script to start server
β”œβ”€β”€ lib/
β”‚   └── wapp/            # Wapp framework files
β”‚       β”œβ”€β”€ wapp.tcl
β”‚       β”œβ”€β”€ wapp-routes.tcl
β”‚       β”œβ”€β”€ wapp-static.tcl
β”‚       └── wapp-thread.tcl
β”œβ”€β”€ tests/
β”‚   β”œβ”€β”€ file_manager_test.tcl
β”‚   └── manual/          # Sample files for testing
└── README.md

Architecture

Core Components

  • render_file_manager: Generates HTML directory listings with clickable navigation links
  • wapp-default: Main request handler that serves files or directory listings based on the requested path
  • wapp framework: Handles HTTP requests, routing, and HTML templating

How It Works

  1. The server receives HTTP requests on the specified port
  2. The wapp-default procedure processes each request:
    • If the path is a file: displays file contents in a <pre> block
    • If the path is a directory: generates an HTML listing of contents
    • If the path doesn't exist: shows "File Not Found" error
  3. Directory listings include clickable links for navigation

Testing

Run the test suite:

tclsh tests/file_manager_test.tcl

The tests/manual/ directory contains sample files of various types for testing the file viewer functionality.

Configuration

Changing the Default Port

Edit run_server.sh or pass a different port when starting manually:

tclsh file_manager.tcl --server 9000

Changing the Root Directory

The server starts browsing from the current working directory. To serve a different directory:

cd /path/to/serve
tclsh /path/to/TCL-Web-File-Manager/file_manager.tcl --server 8080

Security Considerations

⚠️ Important Security Notes:

  • This application is intended for local development and testing only
  • No input validation is performed on file paths
  • Vulnerable to directory traversal attacks if exposed to untrusted networks
  • No authentication or authorization mechanisms
  • All files in the served directory are accessible via the web interface

Recommendations for Production Use:

  • Add input validation and sanitization
  • Implement authentication and authorization
  • Use HTTPS instead of HTTP
  • Restrict file access permissions
  • Run behind a reverse proxy with security headers
  • Consider using a more robust web framework

Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Troubleshooting

Common Issues

"can't find package fileutil"

# Install tcllib package
sudo apt install tcllib  # Ubuntu/Debian
sudo yum install tcllib  # CentOS/RHEL

"Permission denied" when running run_server.sh

chmod +x run_server.sh

Server not accessible from other machines The server binds to localhost by default. To make it accessible from other machines, you may need to modify the wapp configuration (consult wapp documentation for network binding options).

Dependencies

  • wapp: Minimalistic web application framework for TCL (included in lib/wapp/)
  • fileutil: File utilities from tcllib package
  • TCL 8.6+: Core TCL interpreter

Acknowledgments

  • Built with the wapp web framework
  • Uses tcllib for file utilities

About

Lightweight web-based file manager built in TCL using the wapp framework. Browse directories and view files through a simple web interface.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages