Weblish is a lightweight JavaScript extension that allows developers to write natural language (English) instructions within HTML using <script type="text/english">, which are then dynamically compiled into executable JavaScript using Google Gemini.
Features
- 🔤 Write logic in English inside HTML.
- ⚙️ Translates natural language to JavaScript on the fly.
- 🌐 FastAPI backend with Gemini 2.0 Flash support.
- 🧠 LLM-powered code generation.
- 💡 CORS-enabled for client-side integration.
- ✅ Pluggable and extensible runtime design.
Table of Contents
Project Structure
.
├── browser/
│ └── bridge.js # Client-side script loader and runtime
├── example.html # Demo page using <script type="text/english">
├── main.py # FastAPI backend and compiler logic
├── requirements.txt # Backend dependencies
└── .env # Local environment variables (not tracked)
Getting Started
Prerequisites
- Python 3.8+
- Google Generative AI API Key
Installation
- Clone the repository:
git clone https://github.com/ByteJoseph/weblish.git
- Create and configure your
.envfile:
GOOGLE_API_KEY=your_api_key_here
- Install dependencies:
pip install -r requirements.txt
- Run the server:
uvicorn main:app --reload
The backend will be available at http://127.0.0.1:8000/.
Usage
Embed Weblish into your HTML page:
<script src="https://weblish.onrender.com"></script> <script type="text/english"> show hi on the screen as an alert // write your instructions here </script>
This sends "show hi on the screen as an alert" to the backend, which returns and executes corresponding JavaScript code via
eval().
Remote Usage (Deployed):
<script src="https://weblish.onrender.com"></script>
API Endpoints
| Method | Endpoint | Description |
|---|---|---|
| GET | / |
Returns minified bridge.js client script |
| GET | /compile?script= |
Compiles natural language to JavaScript |
| GET | /health |
Health check |
| GET | /license |
Returns the license file content |
Contributing
Contributions are welcome and encouraged! To contribute:
- Fork the repository
- Create a new branch (
git checkout -b feature-name) - Make your changes
- Commit your changes (
git commit -m "Add feature") - Push to the branch (
git push origin feature-name) - Open a pull request
Guidelines
- Follow consistent code style
- Document public functions and endpoints
- Avoid breaking existing functionality
Security Notice
⚠️ Important:
This project executes LLM-generated code usingeval()inside the browser. Do not use in production environments or with untrusted input.
Use only in educational, experimental, or sandboxed scenarios.
License
See LICENSE or access it via the /license endpoint.
Maintainers
- ByteJoseph – Creator & Maintainer