├── static
├── images
│ ├── loader.gif
│ └── default-thumbnail.jpg
├── photos
│ ├── Party
│ │ ├── Thumbs.db
│ │ ├── IMG_20160812_171153.jpg
│ │ └── IMG_20160829_204027.jpg
│ └── cars
│ │ └── IMG_20160920_073221.jpg
├── css
│ ├── ie10.css
│ ├── thumbnail-gallery.css
│ └── signin.css
└── js
│ └── myscript.js
├── __pycache__
└── definition.cpython-36.pyc
├── definition.py
├── modules
├── __pycache__
│ ├── Login.cpython-36.pyc
│ ├── Photos.cpython-36.pyc
│ └── Gallery.cpython-36.pyc
├── Photos.py
├── Login.py
└── Gallery.py
├── .idea
├── inspectionProfiles
│ ├── Project_Default.xml
│ └── profiles_settings.xml
├── modules.xml
├── photo-gallery-python-flask.iml
├── misc.xml
└── workspace.xml
├── data
└── credentials.json
├── templates
├── index.html
├── photos.html
├── gallery.html
└── _layout.html
└── main.py
/static/images/loader.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sumairz/photo-gallery-python-flask/HEAD/static/images/loader.gif
--------------------------------------------------------------------------------
/static/photos/Party/Thumbs.db:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sumairz/photo-gallery-python-flask/HEAD/static/photos/Party/Thumbs.db
--------------------------------------------------------------------------------
/static/images/default-thumbnail.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sumairz/photo-gallery-python-flask/HEAD/static/images/default-thumbnail.jpg
--------------------------------------------------------------------------------
/__pycache__/definition.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sumairz/photo-gallery-python-flask/HEAD/__pycache__/definition.cpython-36.pyc
--------------------------------------------------------------------------------
/definition.py:
--------------------------------------------------------------------------------
1 | # Credential File link
2 | CREDENTIALS_FILE = "data/credentials.json"
3 |
4 | # Folder Paths
5 | Gallery_Folder = "static/photos/"
--------------------------------------------------------------------------------
/modules/__pycache__/Login.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sumairz/photo-gallery-python-flask/HEAD/modules/__pycache__/Login.cpython-36.pyc
--------------------------------------------------------------------------------
/modules/__pycache__/Photos.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sumairz/photo-gallery-python-flask/HEAD/modules/__pycache__/Photos.cpython-36.pyc
--------------------------------------------------------------------------------
/modules/__pycache__/Gallery.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sumairz/photo-gallery-python-flask/HEAD/modules/__pycache__/Gallery.cpython-36.pyc
--------------------------------------------------------------------------------
/static/photos/Party/IMG_20160812_171153.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sumairz/photo-gallery-python-flask/HEAD/static/photos/Party/IMG_20160812_171153.jpg
--------------------------------------------------------------------------------
/static/photos/Party/IMG_20160829_204027.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sumairz/photo-gallery-python-flask/HEAD/static/photos/Party/IMG_20160829_204027.jpg
--------------------------------------------------------------------------------
/static/photos/cars/IMG_20160920_073221.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sumairz/photo-gallery-python-flask/HEAD/static/photos/cars/IMG_20160920_073221.jpg
--------------------------------------------------------------------------------
/.idea/inspectionProfiles/Project_Default.xml:
--------------------------------------------------------------------------------
1 |
No Photos Found
{{ gallery }}
46 | 47 | 48 |No Galleries Found
');
8 |
9 | $.post("/login", {username: user, password: password}, function (response) {
10 |
11 | $("#loader").html('');
12 | var response = JSON.parse(response);
13 |
14 | if (response.success) {
15 | window.location.href = nextURL;
16 | }
17 | else {
18 | $("#loader").html('Invalid username/password
'); 19 | } 20 | }); 21 | }); 22 | 23 | 24 | $("#logoutbtn").on("click", function(){ 25 | 26 | $.post("/logout", {action: 'logout'}, function (response) { 27 | 28 | window.location.href = "index.php"; 29 | 30 | }); 31 | }); 32 | 33 | 34 | /***************************** Gallery Actions ******************************/ 35 | // Add Gallery Action 36 | $("#addGallerybtn").on("click", function(){ 37 | var galleryName = $("#galleryName").val(); 38 | 39 | if(galleryName != "") { 40 | $("#loader").html('
');
41 |
42 | $.when($.post("/galleries/add", {galleryName: galleryName}).done(function(response){
43 | $("#loader").html('');
44 | var response = JSON.parse(response);
45 |
46 | if (response.success) {
47 | location.reload();
48 | }
49 | else {
50 | console.log("Error Adding Gallery");
51 | location.reload();
52 | }
53 | }));
54 | }
55 | });
56 |
57 | // Delete Gallery Action
58 | $(document).on("click", '#deleteGallerybtn', function(){
59 | //$("#deleteGallerybtn").on("click", function(){
60 | var galleryName = $(this).data("galleryname");
61 |
62 | if(galleryName != "") {
63 | $("#loader").html('
');
64 |
65 | $.when($.post("/galleries/delete", {galleryName: galleryName}).done(function(response){
66 | $("#loader").html('');
67 | var response = JSON.parse(response);
68 | console.log(response);
69 |
70 | if (response.success) {
71 | location.reload();
72 | }
73 | else {
74 | console.log("Error deleting Gallery");
75 | location.reload();
76 | }
77 | }));
78 | }
79 | });
80 |
81 |
82 | // Edit Gallery Action
83 | $(document).on("click", '#editGallerybtn', function(){
84 | var galleryName = $(this).data("name");
85 | $("#oldGalleryName").val(galleryName);
86 | });
87 |
88 | // Edit Gallery Modal Action
89 | $("#editGalleryModalBtn").on("click", function(){
90 | var newName = $("#newGalleryName").val();
91 | var galleryName = $("#oldGalleryName").val();
92 |
93 | if(galleryName != "") {
94 | $("#loader").html('
');
95 |
96 | $.when($.post("/galleries/edit", {galleryName: galleryName, newName: newName}).done(function(response){
97 | $("#loader").html('');
98 | var response = JSON.parse(response);
99 |
100 | if (response.success) {
101 | location.reload();
102 | }
103 | else {
104 | console.log("Error renaming Gallery");
105 | location.reload();
106 | }
107 | }));
108 | }
109 | });
110 |
111 |
112 |
113 | /***************************** Photos Actions ******************************/
114 | // Delete Photo Action
115 | $(document).on("click", '#deletePhotobtn', function(){
116 | //$("#deletePhotobtn").on("click", function(){
117 | var galleryName = $(this).data("galleryname");
118 | var photoName = $(this).data("photoname");
119 |
120 | if(galleryName != "") {
121 |
122 | $.when($.post("/galleries/album/photos/delete", {galleryName: galleryName, photoName: photoName}).done(function (response) {
123 | var response = JSON.parse(response);
124 |
125 | if (response.success) {
126 | location.reload();
127 | }
128 | else {
129 | console.log("Error Deleting Photo");
130 | location.reload();
131 | }
132 | }));
133 | }
134 | });
135 |
136 |
137 | $(document).on("click", '#popImage', function(){
138 | var imgSrc = $(this).data("imgsrc");
139 | $('#imagepreview').attr('src', imgSrc);
140 | $('#imagemodal').modal('show');
141 | });
142 |
143 | // $('#popImage').on('click', function() {
144 | // $('.imagepreview').attr('src', $(this).find('img').attr('src'));
145 | // $('#imagemodal').modal('show');
146 | // });
--------------------------------------------------------------------------------
/main.py:
--------------------------------------------------------------------------------
1 | from flask import Flask
2 | from flask import sessions
3 | from flask import request
4 | from flask import render_template
5 | from flask import redirect, url_for
6 | from werkzeug.utils import secure_filename
7 | import json
8 | import os
9 | from modules.Login import Login
10 | from modules.Gallery import Gallery
11 | from modules.Photos import Photos
12 | from definition import *
13 |
14 | app = Flask(__name__)
15 | ALLOWED_EXTENSIONS = set(['jpg', 'jpeg'])
16 | session = {}
17 |
18 | '''
19 | for int routes
20 | @app.route('/