Spaces:
Sleeping
Sleeping
from fastapi import FastAPI | |
from fastapi.staticfiles import StaticFiles | |
from fastapi.responses import HTMLResponse | |
from py_mini_racer import py_mini_racer | |
app = FastAPI() | |
app.mount("/static", StaticFiles(directory="static"), name="static") | |
async def index(): | |
# Create an instance of PyMiniRacer | |
ctx = py_mini_racer.MiniRacer() | |
# Read the JavaScript code | |
with open("static/script.js", "r") as file: | |
javascript_code = file.read() | |
# Execute the JavaScript code | |
ctx.execute(javascript_code) | |
# Get the result of the JavaScript execution | |
result = ctx.eval("window.voiceflow.chat.load({ verify: { projectID: '656181267913810007e3e0b5' }, url: 'https://general-runtime.voiceflow.com', versionID: 'production' });") | |
# Return the result as HTML response | |
return HTMLResponse(content=result, status_code=200) | |
#if __name__ == "__main__": | |
# import uvicorn | |
# uvicorn.run(app, host="0.0.0.0", port=8000) |