first pass at seeing if path exists
This commit is contained in:
38
photos.py
Normal file
38
photos.py
Normal file
@@ -0,0 +1,38 @@
|
||||
from wtforms import SubmitField, StringField, HiddenField, validators, Form
|
||||
from flask_wtf import FlaskForm
|
||||
from flask import request, render_template, redirect
|
||||
from main import db, app, ma
|
||||
from sqlalchemy import Sequence
|
||||
from sqlalchemy.exc import SQLAlchemyError
|
||||
from status import st, Status
|
||||
import os
|
||||
from os import path
|
||||
|
||||
from settings import Settings
|
||||
|
||||
|
||||
################################################################################
|
||||
# Class describing Author in the database, and via sqlalchemy, connected to the DB as well
|
||||
################################################################################
|
||||
class Photos(db.Model):
|
||||
id = db.Column(db.Integer, db.Sequence('photos_id_seq'), primary_key=True )
|
||||
name = db.Column(db.String, unique=True, nullable=True )
|
||||
|
||||
def __repr__(self):
|
||||
return "<id: {}, name: {}>".format(self.id, self.name )
|
||||
|
||||
################################################################################
|
||||
# /photos -> show photos from import_path(s)
|
||||
################################################################################
|
||||
@app.route("/photos", methods=["GET"])
|
||||
def photos():
|
||||
sets = Settings.query.filter(Settings.name=="import_path").all()
|
||||
paths= sets[0].value.split("#")
|
||||
image_list=""
|
||||
view_path=""
|
||||
for p in paths:
|
||||
if( path.exists( p ) ):
|
||||
view_path = p
|
||||
return render_template("photos.html", page_title='View Photos', view_path=view_path, alert=st.GetAlert(), message=st.GetMessage() )
|
||||
|
||||
|
||||
Reference in New Issue
Block a user