run on sqlite and be more stable

new_light
Alex 3 years ago
parent a39587085e
commit 27376f4a88

@ -23,11 +23,11 @@ app = Flask(__name__)
app.config['SECRET_KEY'] = 'super secret key' app.config['SECRET_KEY'] = 'super secret key'
#app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:////tmp/mydatabase.db' #app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:////tmp/mydatabase.db'
app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER
app.config['SQLALCHEMY_DATABASE_URI'] = 'rqlite+pyrqlite://localhost:4001/' #app.config['SQLALCHEMY_DATABASE_URI'] = 'rqlite+pyrqlite://localhost:4001/'
app.config['DEBUG'] = True app.config['DEBUG'] = True
app.config['PORT'] = 80 app.config['PORT'] = 80
#app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///' + os.path.join(basedir, 'mydatabase.db') app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///' + os.path.join(basedir, 'mydatabase.db')
db = SQLAlchemy(app) db = SQLAlchemy(app)
light = not os.path.isdir(UPLOAD_FOLDER) light = not os.path.isdir(UPLOAD_FOLDER)
DOMAIN = environ.get('DOMAIN') DOMAIN = environ.get('DOMAIN')

@ -5,7 +5,7 @@ from wtforms import FieldList
from wtforms import Form as NoCsrfForm from wtforms import Form as NoCsrfForm
from wtforms.fields import StringField, FormField, SubmitField, SelectField, RadioField from wtforms.fields import StringField, FormField, SubmitField, SelectField, RadioField
from app.models import Book, BookSchema, Author, Stack, StackSchema from app.models import Book, BookSchema, Author, Stack, StackSchema
from wtforms.fields.html5 import DecimalRangeField from wtforms.fields import DecimalRangeField
# - - - Forms - - - # - - - Forms - - -
@ -80,6 +80,6 @@ class SearchForm(FlaskForm):
('Outliers', 'Outliers')] ('Outliers', 'Outliers')]
select = SelectField('', choices=choices, default='All') select = SelectField('', choices=choices, default='All')
search = StringField('', validators=[InputRequired()]) search = StringField('', validators=[InputRequired()])
grid = SubmitField('Grid') # grid = SubmitField('Grid')
listview = SubmitField('List') # listview = SubmitField('List')
randomize = SubmitField('Order differently') randomize = SubmitField('Order differently')

@ -1,8 +1,7 @@
from app import db from app import db
from marshmallow import Schema, fields, ValidationError, pre_load from marshmallow import Schema, fields, ValidationError, pre_load
import datetime import datetime
from sqlalchemy import Column, Integer, DateTime from sqlalchemy import Column, DateTime
import flask_whooshalchemyplus
authors = db.Table('books_authors', authors = db.Table('books_authors',

@ -1,22 +1,23 @@
@import url("../fonts/fonts_style.css"); @import url("../fonts/fonts_style.css");
*{ *{
font-family: "Archivo Narrow"; font-family: "Archivo Narrow", Helvetica, sans-serif;
}
body{
background-color: #f1f1f1;
} }
p{ p{
font-size: 20px; font-size: 20px;
} }
a{ a{
text-decoration: underline; text-decoration: underline;
color: black; color: black;
} }
a:hover{
a:hover{
text-decoration: underline; text-decoration: underline;
color: #0000FF; color: #0000FF;
} }
@ -291,7 +292,8 @@ font-size: 12px;
left:0; left:0;
position: fixed; position: fixed;
font-size: 18px; font-size: 18px;
background-color: yellow; background-color: rgb(0, 3, 170);
color: white;
} }
#annotindication{ #annotindication{

@ -50,7 +50,8 @@
<script type="text/javascript" src="{{ url_for("static", filename="js/jquery.tablesorter.js") }}"></script> <script type="text/javascript" src="{{ url_for("static", filename="js/jquery.tablesorter.js") }}"></script>
<script src="{{ url_for("static", filename="js/app.js") }}"></script> <script src="{{ url_for("static", filename="js/app.js") }}"></script>
<script src="{{ url_for("static", filename="js/vendor/socket.io.slim.js") }}"></script> <!-- <script src="{{ url_for("static", filename="js/vendor/socket.io.slim.js") }}"></script> -->
<script src="https://cdn.socket.io/4.4.0/socket.io.min.js" integrity="sha384-1fOn6VtTq3PWwfsOrk45LnYcGosJwzMHv+Xh/Jx5303FVOXzEnw0EpLv30mtjmlj" crossorigin="anonymous"></script>
<script src="{{ url_for("static", filename="js/vendor/vue.min.js") }}"></script> <script src="{{ url_for("static", filename="js/vendor/vue.min.js") }}"></script>
<script> <script>

@ -2,13 +2,14 @@
<ul> <ul>
<li><a href="{{ url_for('home') }}">Home</a></li> <li><a href="{{ url_for('home') }}">Home</a></li>
<li><a href="{{ url_for('show_books') }}">Catalogue</a></li> <li><a href="{{ url_for('show_books') }}">Catalogue</a></li>
<li><a href="{{ url_for('show_stacks') }}">Stacks</a></li>
{%if light%} {%if light%}
{%else%} {%else%}
<li><a href="{{ url_for('add_book') }}">Add Book</a></li> <li><a href="{{ url_for('add_book') }}">Add Book</a></li>
<li><a href="{{ url_for('show_stacks') }}">Stacks</a></li>
<li><a href="{{ url_for ('add_stack') }}">Add Stack</a></li> <li><a href="{{ url_for ('add_stack') }}">Add Stack</a></li>
{%endif%} {%endif%}
<li><a href="{{ url_for('annotations') }}">Annotations</a></li> <!-- <li><a href="{{ url_for('annotations') }}">Annotations</a></li> -->
<li><a href="{{ url_for('about') }}">About</a></li> <li><a href="{{ url_for('about') }}">About</a></li>
{%if light%} {%if light%}
{%else%} {%else%}

@ -40,7 +40,7 @@ fill: yellow;
<body> <body>
<script> <script>
console.log("hello");
// d3.json("/api/books").then(function(data){ // d3.json("/api/books").then(function(data){
// console.log("loaded"); // console.log("loaded");
// console.log(data) // console.log(data)

@ -8,10 +8,8 @@
<div>{{ form.select(style="width: 100px; margin: 10px; float: left; font-size: 20px") }}</div> <div>{{ form.select(style="width: 100px; margin: 10px; float: left; font-size: 20px") }}</div>
<div class="search"> <div class="search">
{{ render_field(form.search) }} </div> {{ render_field(form.search) }} </div>
<button type="submit" @click="sendMessage" class="button is-info" >browse</button> <button type="submit" @click="sendMessage" class="button is-info" >find</button>
<p><br> <p><br>
{{ form.grid(style="font-size:20px")}}{{ form.listview(style="font-size:20px")}}</p>
</form> </form>
<h1 class="page-header">All Books</h1> <h1 class="page-header">All Books</h1>

@ -33,7 +33,7 @@ import sys
from werkzeug.utils import secure_filename from werkzeug.utils import secure_filename
# import sqlite3 # import sqlite3
ALLOWED_EXTENSIONS = set(['txt', 'pdf', 'epub', 'chm', 'mobi']) ALLOWED_EXTENSIONS = set(['txt', 'pdf', 'epub', 'chm', 'mobi', "png", "mp3"])
author_schema = AuthorSchema() author_schema = AuthorSchema()
authors_schema = AuthorSchema(many=True) authors_schema = AuthorSchema(many=True)
@ -123,17 +123,6 @@ def annotations_pdf():
html = render_template(('annotations.html'), annot=annot, light=light) html = render_template(('annotations.html'), annot=annot, light=light)
return render_pdf(HTML(string=html)) return render_pdf(HTML(string=html))
# @app.route('/myannotations.pdf')
# def myannotations_pdf():
# books = db.session.query(Book).all()
# name=str(request.args.get('query'))
# annot = get_annotations()
# res = get_annot_results(annot,name)
# # Make a PDF straight from HTML in a string.
# html = render_template('results_annot.html', name=name, annot=annot, res=res, books=books)
# return render_pdf(HTML(string=html))
@app.route('/viewpdf/<filename>') @app.route('/viewpdf/<filename>')
def viewtestfile1_file(filename): def viewtestfile1_file(filename):
return redirect("/static/viewer/web/viewer.html?file=%2Fuploads%2F"+urlquote(filename)) return redirect("/static/viewer/web/viewer.html?file=%2Fuploads%2F"+urlquote(filename))
@ -446,6 +435,8 @@ def edit_author_by_id(id):
@app.route('/stacks') @app.route('/stacks')
def show_stacks(): def show_stacks():
stacks = db.session.query(Stack).all() stacks = db.session.query(Stack).all()
print("stacks looooooook")
print(stacks)
return render_template('show_stacks.html', stacks=stacks, light=light) return render_template('show_stacks.html', stacks=stacks, light=light)
@app.route('/stacks/add_stack', methods=['POST', 'GET']) @app.route('/stacks/add_stack', methods=['POST', 'GET'])
@ -462,6 +453,7 @@ def add_stack():
if form.stack_name.data: if form.stack_name.data:
stack = Stack(stack_name, stack_description, stack_author) stack = Stack(stack_name, stack_description, stack_author)
db.session.add(stack) db.session.add(stack)
db.session.commit()
stacks = db.session.query(Stack).all() stacks = db.session.query(Stack).all()
return redirect(url_for('show_stacks')) return redirect(url_for('show_stacks'))
flash("%s stack created" % (stack_name)) flash("%s stack created" % (stack_name))
@ -561,15 +553,15 @@ def show_books():
view.append('1') view.append('1')
viewby = '1' viewby = '1'
if search.grid.data: # if search.grid.data:
viewby = '2' # viewby = '2'
view.append('2') # view.append('2')
return render_template ('show_books_grid.html', books=books, form=search, light=light) # return render_template ('show_books_grid.html', books=books, form=search, light=light)
if search.listview.data: # if search.listview.data:
viewby = '1' # viewby = '1'
view.append('1') # view.append('1')
return render_template ('show_books.html', books=books, form=search, light=light) # return render_template ('show_books.html', books=books, form=search, light=light)
if request.method == 'POST': if request.method == 'POST':
newmsg = 'searched for: ' + search.search.data newmsg = 'searched for: ' + search.search.data

@ -1,26 +0,0 @@
appdirs==1.4.0
click==6.7
Flask==0.12
Flask-SQLAlchemy==2.1
Flask-WTF==0.14.2
gunicorn==19.6.0
itsdangerous==0.24
Jinja2==2.9.4
MarkupSafe==0.23
packaging==16.8
pyparsing==2.1.10
six==1.10.0
SQLAlchemy==1.1.5
Werkzeug==0.11.15
WTForms==2.1
flask-marshmallow==0.9.0
Wand==0.4.4
PyPDF2==1.26.0
flask-socketio==2.9.2
flask-whooshalchemyplus==0.7.5
python-dotenv==0.7.1
autocomplete==0.0.104
git+https://github.com/rqlite/pyrqlite.git
git+https://github.com/rqlite/sqlalchemy-rqlite.git
git+https://github.com/Kozea/Flask-WeasyPrint.git
requests=2.20.1
Loading…
Cancel
Save