I tried to code with FastAPI docs, but no way to access js and python callback
Is it possible to use python callback in js and access javascript in FastAPI?
from flask import Flask
from flask import render_template
import jyserver.Flask as jsf
app = Flask(__name__)
@jsf.use(app)
class App:
def __init__(self):
self.count = 0
def increment(self):
self.count += 1
self.js.document.getElementById('count').innerHTML = self.count
@app.route('/')
def index():
return App.render(render_template('index.html'))
if __name__ == '__main__':
app.run()
<!DOCTYPE html>
<html>
<head>
<title>Change DOM</title>
</head>
<body>
<p id="count">0</p>
<button onclick="server.increment()">Increment</button>
</body>
</html>
I want use FastAPI like this...
(jyserver Examples)
reference1 : https://github.com/sohan-py/ChangeDOM
reference2 : https://dev.to/ftrias/access-js-dom-from-flask-app-using-jyserver-23h9
I tried to use async and POST, GET method, but I can't find solutions..