Skip to content

Commit 1ddf190

Browse files
committed
Merge pull request #5 from spaun299/connect_file_manager_upload
Connect file manager upload
2 parents 7df30df + 6ee4d4f commit 1ddf190

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+134
-101
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ Virtualenviroment/
1414
env/
1515
build/
1616
develop-eggs/
17-
dist/
1817
downloads/
1918
eggs/
2019
.eggs/

profapp/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#from .db import db
22
from flask import Flask
3-
from profapp.controllers.views import article_bp, index , filemanager_bp
3+
from profapp.controllers.views import article_bp, index, filemanager_bp
4+
from profapp.controllers.ctrl_filemanager import static_bp
45
#from profapp import views
56

67
def create_app(config='config.ProductionDevelopmentConfig'):
@@ -9,7 +10,7 @@ def create_app(config='config.ProductionDevelopmentConfig'):
910
#db.init_app(app)
1011

1112
app.add_url_rule('/', 'index', index)
12-
13+
app.register_blueprint(static_bp,url_prefix='/static')
1314
app.register_blueprint(article_bp, url_prefix='/articles')
1415
app.register_blueprint(filemanager_bp, url_prefix='/filemanager')
1516
return app
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import os
2+
from time import gmtime, strftime
3+
from stat import *
4+
from flask import jsonify, request, Blueprint
5+
6+
files = os.listdir('/home/viktor/Downloads')
7+
static_bp = Blueprint('static', __name__)
8+
9+
@static_bp.route('/filemanager/bridges/python/ctrl_filemanager.py', methods=['GET', 'POST'])
10+
def ctrl_filemanager():
11+
for params in request.json.values():
12+
if params['mode'] == 'list':
13+
print(listing())
14+
return jsonify(listing())
15+
16+
17+
18+
def listing():
19+
20+
info = []
21+
for file in files:
22+
st = os.stat('/home/viktor/Downloads/'+file)
23+
params = dict()
24+
params['size'] = st[ST_SIZE]
25+
params['date'] = strftime("%Y-%d-%m %X", gmtime(st[ST_MTIME]))
26+
params['name'] = os.path.basename(file)
27+
params['rights'] = 'drwxr-xr-x'
28+
if os.path.isfile('/home/viktor/Downloads/'+file):
29+
params['type'] = 'file'
30+
else :
31+
params['type'] = 'dir'
32+
info.append(params)
33+
file_list = {"result": info}
34+
return file_list
35+
36+

profapp/controllers/views.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,24 @@
1-
from flask import render_template, redirect, url_for, request
1+
from flask import render_template, redirect, url_for, request, jsonify
22
from profapp.controllers.forms import ArticleForm
33
from profapp.models.articles import Article, ArticleHistory
44
from profapp.models.users import User
55
from profapp.models.company import Company
66
from db_connect import sql_session
77
#from config import POSTS_PER_PAGE
8-
8+
import os
99
from flask import Blueprint
1010

1111
article_bp = Blueprint('articles', __name__)
1212
filemanager_bp = Blueprint('filemanager', __name__)
13+
1314
#filemanager_bp = Blueprint('filemanager', __name__,static_folder='../static',static_url_path='')
1415

15-
@article_bp.route('/article/', methods=['GET','POST'])
16+
@article_bp.route('/article/', methods=['GET', 'POST'])
1617
@article_bp.route('/article/<int:page>', methods=['GET', 'POST'])
1718
def article(page=1):
1819

1920
form = ArticleForm()
20-
posts = ArticleHistory.query.filter(ArticleHistory.id==page)
21+
posts = ArticleHistory.query.filter(ArticleHistory.id == page)
2122

2223
if form.validate_on_submit():
2324
article_history=ArticleHistory(form.name.data,form.article.data, 0,
@@ -46,7 +47,7 @@ def article(page=1):
4647
def index():
4748
return render_template('index.html')
4849

49-
@filemanager_bp.route('/',methods=['GET','POST'])
50+
@filemanager_bp.route('/', methods=['GET', 'POST'])
5051
def filemanager():
5152
#return filemanager_bp.send_static_file('index.html')
5253
return render_template('filemanager.html')

profapp/static/angular-filemanager/.bower.json

Lines changed: 0 additions & 38 deletions
This file was deleted.

profapp/static/angular-filemanager/assets/js/config.js

Lines changed: 0 additions & 39 deletions
This file was deleted.

profapp/static/angular-filemanager/bridges/pyhon/ctrl_filemanager.py

Lines changed: 0 additions & 4 deletions
This file was deleted.
File renamed without changes.

0 commit comments

Comments
 (0)