File size: 1,100 Bytes
def6c22
 
 
5313a64
 
def6c22
5313a64
def6c22
 
 
 
 
 
5313a64
def6c22
 
5313a64
def6c22
 
5313a64
def6c22
 
5313a64
def6c22
 
 
 
5313a64
def6c22
5313a64
def6c22
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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

@app.route("/generate_video", methods=["POST"])
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)