Spaces:
Build error
Build error
Commit ·
edd1925
1
Parent(s): 7671124
Update main.py
Browse files
main.py
CHANGED
|
@@ -115,8 +115,25 @@ def video_feed():
|
|
| 115 |
def home():
|
| 116 |
return jsonify(message='Welcome to the Hugging Face Space!')
|
| 117 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 118 |
@app.route('/get_frames', methods=['GET'])
|
| 119 |
def get_frames():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 120 |
frames = Frame.query.all()
|
| 121 |
frames_data = []
|
| 122 |
|
|
@@ -128,6 +145,14 @@ def get_frames():
|
|
| 128 |
|
| 129 |
return jsonify(frames_data)
|
| 130 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 131 |
if __name__ == '__main__':
|
| 132 |
with app.app_context():
|
| 133 |
create_database()
|
|
|
|
| 115 |
def home():
|
| 116 |
return jsonify(message='Welcome to the Hugging Face Space!')
|
| 117 |
|
| 118 |
+
from flask import Flask, jsonify
|
| 119 |
+
import os
|
| 120 |
+
|
| 121 |
+
app = Flask(__name__)
|
| 122 |
+
|
| 123 |
@app.route('/get_frames', methods=['GET'])
|
| 124 |
def get_frames():
|
| 125 |
+
instance_folder = app.instance_path
|
| 126 |
+
db_file_path = os.path.join(instance_folder, 'faces.db')
|
| 127 |
+
|
| 128 |
+
# Check if the instance folder is present
|
| 129 |
+
if not os.path.exists(instance_folder):
|
| 130 |
+
return jsonify({'error': 'Instance folder not present'}), 500
|
| 131 |
+
|
| 132 |
+
# Check if the faces.db file exists
|
| 133 |
+
if not os.path.exists(db_file_path):
|
| 134 |
+
return jsonify({'error': 'faces.db not present in the instance folder'}), 500
|
| 135 |
+
|
| 136 |
+
# Continue with the normal operation if everything is present
|
| 137 |
frames = Frame.query.all()
|
| 138 |
frames_data = []
|
| 139 |
|
|
|
|
| 145 |
|
| 146 |
return jsonify(frames_data)
|
| 147 |
|
| 148 |
+
# Assuming you have a Frame model defined somewhere in your code
|
| 149 |
+
class Frame:
|
| 150 |
+
pass # Your Frame model definition goes here
|
| 151 |
+
|
| 152 |
+
if __name__ == '__main__':
|
| 153 |
+
app.run(debug=True)
|
| 154 |
+
|
| 155 |
+
|
| 156 |
if __name__ == '__main__':
|
| 157 |
with app.app_context():
|
| 158 |
create_database()
|