Update app.py
Browse files
app.py
CHANGED
@@ -6,45 +6,49 @@ import os
|
|
6 |
app = Flask(__name__)
|
7 |
CORS(app)
|
8 |
|
9 |
-
@app.route('/get_video')
|
10 |
def get_video():
|
11 |
-
|
12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
|
14 |
-
|
15 |
-
The overall chemical equation for photosynthesis is:
|
16 |
-
**6CO₂ + 6H₂O + Light Energy → C₆H₁₂O₆ (glucose) + 6O₂**
|
17 |
-
|
18 |
-
#### **1. Light-Dependent Reactions (Occur in Thylakoids of Chloroplasts)**
|
19 |
-
- Chlorophyll (the green pigment in leaves) absorbs sunlight.
|
20 |
-
- Water (H₂O) is split into oxygen (O₂), protons (H⁺), and electrons (e⁻).
|
21 |
-
- Oxygen is released as a byproduct (essential for life!).
|
22 |
-
- Energy from sunlight is stored in **ATP** and **NADPH** (energy carriers).
|
23 |
-
|
24 |
-
#### **2. Calvin Cycle (Light-Independent Reactions, Occurs in Stroma)**
|
25 |
-
- Uses **ATP** and **NADPH** from the light reactions.
|
26 |
-
- Carbon dioxide (CO₂) from the air is fixed and converted into glucose.
|
27 |
-
- This process does **not** require light directly but depends on the products of light reactions.
|
28 |
-
|
29 |
-
|
30 |
-
.
|
31 |
-
|
32 |
-
otosynthesis is the process by which green plants, algae, and some bacteria make their own food using sunlight. It mainly occurs in the leaves of plants..."""
|
33 |
-
prompts = [
|
34 |
-
"photosynthesis process diagram",
|
35 |
-
"green leaves with chlorophyll",
|
36 |
-
"plant roots absorbing water",
|
37 |
-
"sunlight on leaves",
|
38 |
-
"plant releasing oxygen",
|
39 |
-
"chemical equation photosynthesis",
|
40 |
-
"plants supporting life on Earth"
|
41 |
-
]
|
42 |
-
video_path = video_generation(text,prompts)
|
43 |
-
video_url = f"https://sreepathi-ravikumar-backendprocess.hf.space/{os.path.basename(video_path)}"
|
44 |
-
if not os.path.exists(video_file):
|
45 |
-
return jsonify("Video file not found.")
|
46 |
|
47 |
-
|
|
|
48 |
|
49 |
# Construct URL (adjust domain/port if needed)
|
50 |
|
|
|
6 |
app = Flask(__name__)
|
7 |
CORS(app)
|
8 |
|
9 |
+
@app.route('/get_video', methods=['POST'])
|
10 |
def get_video():
|
11 |
+
try:
|
12 |
+
text = """
|
13 |
+
**Photosynthesis** is the biological process by which green plants, algae, and some bacteria convert light energy (usually from the sun) into chemical energy stored in glucose (a type of sugar). This process is fundamental to life on Earth, as it produces oxygen and provides energy for nearly all ecosystems.
|
14 |
+
|
15 |
+
### **Key Steps of Photosynthesis**
|
16 |
+
The overall chemical equation for photosynthesis is:
|
17 |
+
**6CO₂ + 6H₂O + Light Energy → C₆H₁₂O₆ (glucose) + 6O₂**
|
18 |
+
|
19 |
+
#### **1. Light-Dependent Reactions (Occur in Thylakoids of Chloroplasts)**
|
20 |
+
- Chlorophyll (the green pigment in leaves) absorbs sunlight.
|
21 |
+
- Water (H₂O) is split into oxygen (O₂), protons (H⁺), and electrons (e⁻).
|
22 |
+
- Oxygen is released as a byproduct (essential for life!).
|
23 |
+
- Energy from sunlight is stored in **ATP** and **NADPH** (energy carriers).
|
24 |
+
|
25 |
+
#### **2. Calvin Cycle (Light-Independent Reactions, Occurs in Stroma)**
|
26 |
+
- Uses **ATP** and **NADPH** from the light reactions.
|
27 |
+
- Carbon dioxide (CO₂) from the air is fixed and converted into glucose.
|
28 |
+
- This process does **not** require light directly but depends on the products of light reactions.
|
29 |
+
|
30 |
+
|
31 |
+
.
|
32 |
+
|
33 |
+
otosynthesis is the process by which green plants, algae, and some bacteria make their own food using sunlight. It mainly occurs in the leaves of plants..."""
|
34 |
+
prompts = [
|
35 |
+
"photosynthesis process diagram",
|
36 |
+
"green leaves with chlorophyll",
|
37 |
+
"plant roots absorbing water",
|
38 |
+
"sunlight on leaves",
|
39 |
+
"plant releasing oxygen",
|
40 |
+
"chemical equation photosynthesis",
|
41 |
+
"plants supporting life on Earth"
|
42 |
+
]
|
43 |
+
video_path = video_generation(text,prompts)
|
44 |
+
video_url = f"https://sreepathi-ravikumar-backendprocess.hf.space/{os.path.basename(video_path)}"
|
45 |
+
if not os.path.exists(video_file):
|
46 |
+
return jsonify("Video file not found.")
|
47 |
|
48 |
+
return jsonify({"video_url": video_url})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
|
50 |
+
except Exception as e:
|
51 |
+
return jsonify({"error": str(e)}), 500
|
52 |
|
53 |
# Construct URL (adjust domain/port if needed)
|
54 |
|