Skip to main content

Teloce-Py

teloce-py logo

Build interactive Python applications with .vel files. Teloce-Py compiles the template, browser behavior, and component CSS into normal browser assets; Flask, FastAPI, Django, or Flaxon remains responsible for routes, APIs, databases, authentication, and security.

The problem it solves

Python teams often maintain a backend template system and a separate frontend toolchain just to build forms, dashboards, and reactive UI. Teloce keeps the interactive part in readable .vel components while preserving the Python framework you already use.

Fast workflow: write .vel, run python app.py

static/js/App.vel -> app.py builds it -> Python serves the page -> browser runs it

Recommended layout:

my-app/
├── app.py
├── teloce.config.json
├── static/js/App.vel       # authored source
├── templates/index.html    # HTML shell and #app mount
└── dist/                   # generated output; never edit by hand

Copy-paste Flask example

Install:

python -m pip install teloce-py Flask

Create static/js/App.vel:

<template>
  <main class="chat">
    <h1>Quick chat</h1>
    <ul><li v-for="message in messages" :key="message.id">{{ message.text }}</li></ul>
    <form @submit.prevent="send">
      <input v-model="draft" aria-label="Message" />
      <button>Send</button>
    </form>
  </main>
</template>
<script>
export default {
  data() { return { draft: "", messages: [] }; },
  async mounted() { this.messages = await fetch("/api/messages").then(r => r.json()); },
  methods: {
    async send() {
      const text = this.draft.trim();
      if (!text) return;
      const message = await fetch("/api/messages", {
        method: "POST", headers: {"Content-Type": "application/json"},
        body: JSON.stringify({text})
      }).then(r => r.json());
      this.messages = [...this.messages, message];
      this.draft = "";
    }
  }
};
</script>
<style scoped>
.chat { max-width: 40rem; margin: 3rem auto; padding: 1rem; font: 1rem system-ui; }
form { display: flex; gap: .5rem; } input { flex: 1; padding: .7rem; }
</style>

Create app.py. It builds automatically, so the only development command is python app.py:

from pathlib import Path
from flask import Flask, jsonify, render_template, request
from teloce.build import build_project

ROOT = Path(__file__).parent
build_project(ROOT, out_dir=ROOT / "dist", options={"dev": True})
app = Flask(__name__, static_folder="dist/static", static_url_path="/static")
messages = []

@app.get("/")
def home():
    return render_template("index.html")

@app.get("/api/messages")
def list_messages():
    return jsonify(messages)

@app.post("/api/messages")
def create_message():
    text = str((request.get_json(silent=True) or {}).get("text", "")).strip()
    if not text or len(text) > 500:
        return jsonify({"error": "Message must contain 1-500 characters"}), 400
    message = {"id": len(messages) + 1, "text": text}
    messages.append(message)
    return jsonify(message), 201

if __name__ == "__main__":
    app.run(debug=True)

Create templates/index.html:

<!doctype html><html><head><meta charset="utf-8"><title>Quick chat</title></head>
<body><div id="app"></div>
<script type="module">import { mount } from "{{ url_for('static', filename='js/App.js') }}"; mount("#app");</script>
</body></html>

Run it:

python app.py

Open http://127.0.0.1:5000. This is a real Flask API and compiled .vel UI; it uses in-memory messages for a small demonstration. Add a database, authentication, CSRF protection, and rate limits before production use.

Flaxon and WebSockets

Flaxon is the async option when the app needs rooms and real-time events. The verified pattern is accept(), join(room), receive_json(), and broadcast_json(room, data):

from flaxon import Flaxon
from flaxon.websocket import WebSocket

app = Flaxon("chat", debug=True)

@app.websocket("/ws/chat/<room_id>")
async def chat(socket: WebSocket, room_id: str):
    await socket.accept()
    await socket.join(room_id)
    try:
        async for message in socket.iter_json():
            await socket.broadcast_json(room_id, {
                "text": str(message.get("text", ""))[:500]
            })
    finally:
        await socket.leave(room_id)

Serve the generated asset directory with Flaxon and run the framework's Flaxon command (python -m flaxon run app:app --reload). Use wss:// behind HTTPS. The Flask example above intentionally uses ordinary HTTP so it can be started reliably with only python app.py.

Release checks

teloce lint --strict
teloce build --source-map --hash-assets --bundle --report
python -m pytest -q
python -m build --sdist --wheel
python -m twine check dist/*

Use --bundler esbuild for whole-program tree-shaking, code splitting, and minification. Teloce supports limited common TypeScript syntax stripping, not full TypeScript type-checking. Read the documentation, optimized structure lesson, and all examples: examples/flask-chat, examples/config-driven-flask, examples/fastapi-cms, examples/django-scanner, examples/django-admin-vel, examples/flaxon-network, and examples/teloce-gallery.

Status

Teloce-Py is beta software. Pin versions and test generated browser assets in the Python framework and deployment platform you support.

License

MIT

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

teloce_py-0.2.5.tar.gz (196.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

teloce_py-0.2.5-py3-none-any.whl (237.1 kB view details)

Uploaded Python 3

File details

Details for the file teloce_py-0.2.5.tar.gz.

File metadata

  • Download URL: teloce_py-0.2.5.tar.gz
  • Upload date:
  • Size: 196.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.3

File hashes

Hashes for teloce_py-0.2.5.tar.gz
Algorithm Hash digest
SHA256 ea646d83c8312d454d6c2df5c475ce4eb4e0e706f417ef13aa6e0a8623eaf6b8
MD5 4c4cebe8732c6e54ab6a92b3168747ea
BLAKE2b-256 4f41077ee4f7787fc777f01f8a91daa28d18e7924010cbf358dc6eec9ca74638

See more details on using hashes here.

File details

Details for the file teloce_py-0.2.5-py3-none-any.whl.

File metadata

  • Download URL: teloce_py-0.2.5-py3-none-any.whl
  • Upload date:
  • Size: 237.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.3

File hashes

Hashes for teloce_py-0.2.5-py3-none-any.whl
Algorithm Hash digest
SHA256 0ccf12ea4b6ff1f628a31a7d4e05fcf9880814d067eddb9d0d7d147851e8f15f
MD5 46f5b2115414fba1aabbce09cb0cfb53
BLAKE2b-256 e28a0574d4568d15ccab22ebe96267a0068f16ad946b23bece83e36cc7330993

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.2.5 This release

2 files

0.2.4

2 files

0.2.3

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page