DEV Community

Momin Iqbal
Momin Iqbal

Posted on

Spin-Python-SDK Templete

What is Spin
Spin is a framework for building and running event-driven microservice applications with WebAssembly (Wasm) components.

Spin Templete
spin templete is the layer of Spin-python-sdk for render html

How to install spin_templete

pip install spin_templete
Enter fullscreen mode Exit fullscreen mode

Setup

mkdir templete
cd templete
touch index.html
Enter fullscreen mode Exit fullscreen mode

index.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <h1>Hello World Again Momin</h1>

    <ul>
        {% for item in items %}
            <li>{{ item }}</li>
        {% endfor %}
        </ul>   
    <ul>
        {% for item in mylist %}
            <li>{{ item }}</li>
        {% endfor %}
        </ul>   



<h1>{{name}}</h1>

</body>
</html>
Enter fullscreen mode Exit fullscreen mode

app.py

from spin_sdk.http import IncomingHandler, Request, Response
from spintemplete.templete import Render


html = Render("templete")

class IncomingHandler(IncomingHandler):
    def handle_request(self, request: Request) -> Response:
        return html.render("index.html",items=[1,2,3,4,5],mylist=["hello","world"],name="momin")
Enter fullscreen mode Exit fullscreen mode

spin.toml
Add more html files your requirements


[component.myapp]
source = "app.wasm"
files = ["templete/index.html"]
Enter fullscreen mode Exit fullscreen mode

Repository : https://github.com/MominIqbal-1234/spin_templete
Developed by : Momin Iqbal
site : https://image.mefiz.com

Image of Datadog

How to Diagram Your Cloud Architecture

Cloud architecture diagrams provide critical visibility into the resources in your environment and how they’re connected. In our latest eBook, AWS Solution Architects Jason Mimick and James Wenzel walk through best practices on how to build effective and professional diagrams.

Download the Free eBook

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more