diasporadiaries

a platform for writing stories with personal accounts and messages
git clone git://parazyd.org/diasporadiaries.git
Log | Files | Refs | Submodules | README | LICENSE

commit e29b29d7e52fdfe95b49a40efa18de1c4c100daf
parent d1f16d0383b15ce2c55a50779aaf8ab0e3947481
Author: parazyd <parazyd@dyne.org>
Date:   Sun, 27 Jan 2019 15:56:59 +0100

Move the executable to a separate file and use bjoern for production.

Diffstat:
MREADME.md | 4++--
Mdiaspora.py | 17+----------------
Arun.py | 42++++++++++++++++++++++++++++++++++++++++++
3 files changed, 45 insertions(+), 18 deletions(-)

diff --git a/README.md b/README.md @@ -11,7 +11,7 @@ Deploying ### Dependencies ``` -python3 python3-flask python3-flask-login python3-bcrypt +python3 python3-flask python3-flask-login python3-bcrypt python3-bjoern ``` DiasporaDiaries runs as a standalone HTTP server and is supposed to be @@ -45,7 +45,7 @@ server { ssl_certificate_key /etc/ssl/diaspora.key; location / { - proxy_pass http://127.0.0.1:8000; + proxy_pass http://127.0.0.1:8000/; proxy_set_header Host $host; } } diff --git a/diaspora.py b/diaspora.py @@ -18,7 +18,6 @@ """ Main diasporadiaries module """ -from argparse import ArgumentParser from random import choice from time import time @@ -281,8 +280,7 @@ def edit(): if story: if current_user.is_admin or current_user.username == story['email']: return render_template('edit.html', story=story) - else: - return render_template('fail.html', msg='Unauthorized.') + return render_template('fail.html', msg='Unauthorized.') return render_template('fail.html', msg='No story with this story id.') @@ -491,16 +489,3 @@ def main(): stories = get_recent_stories() profiles = get_profiles_from_stories(stories) return render_template('index.html', stories=stories, profiles=profiles) - - -if __name__ == '__main__': - parser = ArgumentParser() - parser.add_argument('-l', default='127.0.0.1', - help='Address for listening (ex: 127.0.0.1)') - parser.add_argument('-p', default='8000', - help='Port for listening (ex: 8000)') - parser.add_argument('-d', action='store_true', default=False, - help='Debug mode') - args = parser.parse_args() - - app.run(host=args.l, port=args.p, threaded=True, debug=args.d) diff --git a/run.py b/run.py @@ -0,0 +1,42 @@ +#!/usr/bin/env python3 +# Copyright (c) 2019 Ivan Jelincic <parazyd@dyne.org> +# +# This file is part of diasporadiaries +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +""" +Module/executable to start diasporadiaries +""" + +from argparse import ArgumentParser + +from bjoern import run + +from diaspora import app + + +if __name__ == '__main__': + parser = ArgumentParser() + parser.add_argument('-l', default='127.0.0.1', + help='Address for listening (ex: 127.0.0.1)') + parser.add_argument('-p', default=8000, + help='Port for listening (ex: 8000)') + parser.add_argument('-d', action='store_true', default=False, + help='Debug mode') + args = parser.parse_args() + + if args.d: + app.run(host=args.l, port=args.p, threaded=True, debug=args.d) + + run(app, args.l, args.p)