Python
This guide will show how to use hop in a Python project.
We start by writing a simple hop file.
hop
<Index {name: String}>
Hello {name}!
</Index>Now we compile the hop code to native Python code.
bash
hop compileNow the generated Python code is available in the folder ./frontend so we can import it in the backend.
Now, let's define a simple backend using Flask.
python
from flask import Flask
import frontend
app = Flask(__name__)
@app.route('/')
def index():
return frontend.page_index(
frontend.PageIndexParams(
name="Tobi"
)
)
if __name__ == '__main__':
app.run(port=8080)Now hop is integrated into the backend, and we can run hop dev to start the server and get hot-reloading.