Spaces:
Runtime error
Runtime error
import requests | |
from flask import Flask, request, jsonify | |
from flask_ngrok import run_with_ngrok | |
app = Flask(__name__) | |
run_with_ngrok(app) # Start ngrok when the app is run | |
def generate_video(): | |
# This is a placeholder for your video generation logic | |
# You would need to replace this with your actual implementation | |
text = request.json.get("text", "") | |
# ... your video generation logic here ... | |
# For demonstration, we'll return a simple message | |
return jsonify({"message": f"Video generated for text: {text}"}) | |
if __name__ == "__main__": | |
app.run() | |
# In a separate cell or script, make the request: | |
import requests | |
# Replace with the actual ngrok URL you get after running the Flask app | |
ngrok_url = "http://<your_ngrok_url>.ngrok.io" | |
url = f"{ngrok_url}/generate_video" | |
text = {"text": "Hello, this is a sample text-to-video conversion!"} | |
response = requests.post(url, json=text) | |
if response.status_code == 200: | |
print("Success:", response.json()) | |
else: | |
print("Error:", response.status_code, response.text) |