This script is a simple, self-contained backend server written in PowerShell. It is designed to support a local web application by serving static files (HTML, CSS, JavaScript, images) and providing a basic JSON file-based REST API for data persistence. It's intended to be the backend for the "EliteSoftware Southern Branch Corporate Portal".
Built by: Zachary Whiteman & Google Gemini Ai.
This script runs the local web server needed for the frontend application to function.
To run this script, you will need:
- Windows Operating System.
- PowerShell 5.1 or newer.
- .NET Framework: Required for the
HttpListenerclass. - Frontend Files: This script requires the frontend application files (e.g.,
index.html, etc.) to be in the same directory.
- Download: Place the
elitesoftware south department backend.ps1script in the root directory of your web application project. - Unblock: Right-click the file, go to Properties, and click
Unblockif the file was downloaded from the internet. - Run: Execute the script from a PowerShell console.
."\elitesoftware south department backend.ps1" - Access: Keep the PowerShell window running and open your web browser to
http://localhost:8080.
The server provides several API endpoints to interact with the local database.json file and file system.
GET /api/data: Retrieves all data fromdatabase.jsonand dynamically includes any blog posts from the/postsdirectory.POST /api/data: Overwrites the contents ofdatabase.jsonwith the JSON data provided in the request body.GET /api/images: Returns a JSON array of filenames found in the/imagesdirectory.GET /api/videos: Returns a JSON array of filenames found in the/videosdirectory.POST /api/upload: Handles multipart/form-data file uploads and saves them to the/imagesdirectory.
- Local HTTP Server: Runs a simple web server on
http://localhost:8080using the built-in .NETHttpListener. - Static File Serving: Serves HTML, CSS, JS, and media files. Includes a fallback to
index.htmlfor Single Page Application (SPA) routing. - JSON Database: Uses a local
database.jsonfile for simple data persistence. The file is created with default data if it doesn't exist. - RESTful API: Provides basic API endpoints for reading and writing data, listing images/videos, and uploading files.
- CORS Enabled: Automatically includes CORS headers to allow requests from the frontend application.
- Dynamic Post Loading: Automatically discovers and serves text and markdown files from a
/postsdirectory as blog posts.
- Scripting Language: PowerShell
- Web Server: The core web server is implemented using the
.NET System.Net.HttpListenerclass. - Data Format: JSON for the database and API responses.
- Development Only: This server is intended for local development and testing only. It is not secure and should not be exposed to the internet.
- No Authentication: The API endpoints do not have any authentication or authorization mechanisms.
- File System Access: The server reads from and writes to the directory where it is located. Ensure it is run in a trusted project folder.
Distributed under the MIT License. See LICENSE.txt for more information.
Zach Whiteman - elitesoftwarecolimited@gmail.com
HuggingFace - https://huggingface.co/EliteSoftware
HuggingFace (Personal) - https://huggingface.co/TheShadyRainbow
LinkTree - https://linktr.ee/zachrainbow