Web platform for sharing free data for ML and research

By using this site, you agree to have cookies stored on your device, strictly for functional purposes, such as storing your session and preferences.

Dismiss

Get gallery info in API

roundabout,
created on Saturday, 14 September 2024, 11:57:33 (1726315053), received on Saturday, 14 September 2024, 13:01:54 (1726318914)
Author identity: vlad <vlad.muntoiu@gmail.com>

3618079b3159b94c00f34d13bb32cd051b12ba77

app.py

@@ -1557,3 +1557,20 @@ def api_rate_picture(id):

                                
                                
                                
                            
                                
                                    
                                        
                                            
                                            
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                return flask.jsonify({"message": "Rating saved"})
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                            
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        @app.route("/api/gallery/<int:id>/")
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        def api_gallery(id):
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            gallery = db.session.get(Gallery, id)
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            if gallery is None:
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                flask.abort(404)
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            json_gallery = {
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                "id": gallery.id,
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                "title": gallery.title,
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                "description": gallery.description,
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                "owner": gallery.owner_name,
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                "users": [user.username for user in gallery.users],
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            }
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            return flask.jsonify(json_gallery)