Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,58 +1,19 @@
|
|
1 |
-
from flask import Flask, jsonify
|
2 |
-
from
|
3 |
-
from video import video_generation
|
4 |
import os
|
5 |
|
6 |
app = Flask(__name__)
|
7 |
-
CORS(app)
|
8 |
|
9 |
-
@app.route(
|
10 |
-
def
|
11 |
-
|
12 |
-
|
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 |
-
|
51 |
-
|
52 |
-
|
53 |
-
# Construct URL (adjust domain/port if needed)
|
54 |
-
|
55 |
|
56 |
-
|
57 |
-
|
58 |
-
|
|
|
|
1 |
+
from flask import Flask, request, send_file, jsonify
|
2 |
+
from moviepy.editor import ColorClip
|
|
|
3 |
import os
|
4 |
|
5 |
app = Flask(__name__)
|
|
|
6 |
|
7 |
+
@app.route("/generate", methods=["POST"])
|
8 |
+
def generate_video():
|
9 |
+
data = request.get_json()
|
10 |
+
duration = int(data.get("duration", 5)) # Default to 5 seconds if not given
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
|
12 |
+
video_path = "white_video.mp4"
|
13 |
+
clip = ColorClip(size=(640, 360), color=(255, 255, 255), duration=duration)
|
14 |
+
clip.write_videofile(video_path, fps=24)
|
|
|
|
|
15 |
|
16 |
+
return send_file(video_path, mimetype='video/mp4')
|
17 |
+
|
18 |
+
if __name__ == "__main__":
|
19 |
+
app.run(host="0.0.0.0", port=7860)
|