Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated to Python3 and some additional things #62

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ uwsgi.ini
.*.swp
*~
MANIFEST
venv/
122 changes: 122 additions & 0 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,3 +158,125 @@ in the uwsgi.ini file instead of module, like this:
uid = www-data
gid = www-data
logto = /var/log/dnote.log



These are some notes I made for CentOS 7.9, it still needs cleaning, I just needed a place to dump it for now
---------------------------------------------------------------------------------------------------------------

```sh

I still need to update the install notes properly explain exactly how it’s installed but here it is in a nutshell:

Pre-requisites:

Python 3.6.8 (this is the version I used because that’s what comes with CentOS)

The following CentOS packages that are needed for Python3 and http mod_wsgi:

mod_wsgi.x86_64

python3-mod_wsgi.x86_64

python3-libs.x86_64

python3-pip.noarch

python3-setuptools.noarch

Install it all in one command:

yum install python3-mod_wsgi.x86_64 python3-libs.x86_64 python3-pip.noarch python3-setuptools.noarch

Once the above is installed.

Apache is used as the web server, and it uses qsgi to launch the python code.

This is the Apache httpd config file location:

/etc/httpd/conf.d/share-le-ssl.conf

And this is the contents, what’s important is the line that saysWSGIScriptAlias and the few lines below that, the other stuff is unrelated, just putting it here for full context.

# customise the links as per you own deployment

<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerName dnote.domain.com
ServerAdmin [email protected]
ServerAlias www.dnote.domain.com
DocumentRoot /var/www/html
ErrorLog /var/log/httpd/share-error.log
CustomLog /var/log/httpd/share-requests.log combined

WSGIScriptAlias /dnote /var/www/dnote/wsgi.py
<Directory /var/www/dnote/>
Options -Indexes
Options FollowSymLinks
Order allow,deny
Allow from all
</Directory>
Alias /d/static /var/www/dnote/static
<Directory /var/www/dnote/static/>
Order allow,deny
Allow from all
</Directory>

SSLCertificateFile /etc/letsencrypt/live/dnote.domain.com/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/dnote.domain.com/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateChainFile /etc/letsencrypt/live/dnote.domain.com/chain.pem
</VirtualHost>
</IfModule>


Steps to install it are:

clone the git repo from:

git clone [email protected]:Pyroseza/d-note.git

checkout the py3 branch

cd d-note

git checkout py3

zip it up

cd ..

zip -r d-note.zip d-note

upload it to /tmp on your server hosting this: dnote.domain.com

scp d-note.zip dnote.domain.com:/tmp

run these commands:

cd /tmp

rm -rf d-note

unzip d-note.zip

cd d-note/

python3 setup.py install

systemctl restart httpd

tail -f /etc/httpd/logs/share-requests.log /etc/httpd/logs/share-error.log

The bulk of the code gets installed under Python3’s site-packages, here:

/usr/local/lib/python3.6/site-packages/dnote-2.0.0-py3.6.egg/

The wsgi server file gets installed here:

/var/www/dnote/wsgi.py

and the config gets installed here:

/etc/dnote/d-note.ini
```
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ unless otherwise stated. See [the license](LICENSE.md) for the complete license.
Demo
----

If you would like to test drive d-note, I have it running at https://ae7.st/d/.
If you would like to test drive d-note, the original author (Aaron Toponce) has
an older version running at https://ae7.st/d/.
Currently, it is hosted using a self-signed certificate. As such, the
fingerprints of the certificate are:

Expand Down
13 changes: 7 additions & 6 deletions d-note.ini
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@
app = dnote

# search for config files here
config_path = ~/.dnote
data_dir = ~/.dnote/data
#config_path = /.dnote
#data_dir = ~/.dnote/data

# size of bytes used unique url and duress key lengths, don't go lower than 4, 16 is default
byte_size = 16

# in production, use these values
#config_path = /etc/dnote
#data_dir = /var/lib/dnote/data
config_path = /etc/dnote
data_dir = /var/lib/dnote/data

[dnote]
# intentionally left blank.
# Used to interpolate defaults above when they don't get used in another category below


13 changes: 11 additions & 2 deletions dnote/__init__.py
Original file line number Diff line number Diff line change
@@ -1,34 +1,41 @@
#!/usr/bin/env python3

"""This module sets up the paths for the Flask web application."""
import os
import utils
from . import utils
from flask import Flask, render_template, request, redirect, url_for
from note import Note
from .note import Note

DNOTE = Flask(__name__)
HERE = DNOTE.root_path


@DNOTE.route('/', methods=['GET'])
def index():
"""Return the index.html for the main application."""
error = request.args.get('error', None)
note = Note()
return render_template('index.html', random=note.url, error=error)


@DNOTE.route('/security/', methods=['GET'])
def security():
"""Return the index.html for the security page."""
return render_template('security.html')


@DNOTE.route('/faq/', methods=['GET'])
def faq():
"""Return the index.html for the faq page."""
return render_template('faq.html')


@DNOTE.route('/about/', methods=['GET'])
def about():
"""Return the index.html for the about page."""
return render_template('about.html')


@DNOTE.route('/post', methods=['POST'])
def show_post():
"""Return the random URL after posting the plaintext."""
Expand All @@ -52,6 +59,7 @@ def show_post():
note.encrypt()
return render_template('post.html', random=note.url)


@DNOTE.route('/<random_url>', methods=['POST', 'GET'])
def fetch_url(random_url):
"""Return the decrypted note. Begin short destruction timer.
Expand All @@ -77,6 +85,7 @@ def fetch_url(random_url):
else:
return render_template('keyerror.html', random=note.url)


if __name__ == '__main__':
DNOTE.debug = True
DNOTE.run()
Loading