Compare commits

...

8 Commits

7
.gitignore vendored

@ -1,3 +1,10 @@
env/
venv/
venv/*
.idea/
__pycache__/
__pycache__/*
app/__pycache__/
app/__pycache__/*
app/static/dewatermark/
app/static/dewatermark/*

@ -0,0 +1,88 @@
# Run
## in Development
`export FLASK_APP=run.py`
`export FLASK_ENV=development`
`flask run`
**Using gunicorn:**
`gunicorn --env SCRIPT_NAME=/watermarks -w 4 -b 127.0.0.1:5000 app:app --log-level debug`
* `-w` workers
* `-b` bind to address / unix socker
**And gunicorn with using unix sock:** (this how it should run in production)
` gunicorn --env SCRIPT_NAME=/watermarks --workers 4 --bind unix:app.sock -m 007 app:app --log-level debug
## in Production with gunicorn and unix sockets
Based on https://medium.com/faun/deploy-flask-app-with-nginx-using-gunicorn-7fda4f50066a
### systemd service file
Add to /etc/systemd/system/watermarks.service
```
[Unit]
After=network.target
[Service]
User=psc
Group=www-data
WorkingDirectory=/var/www/TacticalApp
Environment="PATH=/var/www/TacticalApp/venv/bin"
ExecStart=/var/www/TacticalApp/venv/bin/gunicorn --env SCRIPT_NAME=/watermarks --workers 4 --bind unix:app.sock -m 007 app:app
[Install]
WantedBy=multi-user.target
```
## enable & start service file
`systemctl enable watermarks.service`
`systemctl start watermarks.service`
It is also a good idea to check the status of the service
`systemctl status watermarks.service`
## Nginx config
```
location / {
# if using gunicorn with app sock, use:
proxy_pass http://unix:/var/www/TacticalApp/app.sock;
# if using gunicord with port 5000, use:
proxy_pass http://127.0.0.1:5000;
}
```
## debug.
It might be helpful to enable gunicorn logging, while in development, to check what is going on,
by replacing in watermarks.service, the `ExecStart=` value with:
`ExecStart=/var/www/TacticalApp/venv/bin/gunicorn --log-level debug --error-logfile /var/www/TacticalApp/app.log --workers 4 --bind unix:app.sock -m 007 app:app`
And reloading the services
`systemctl daemon-reload`
`systemctl restart watermarks.service`
and the start following app.log:
`tail -f /var/www/TacticalApp/app.log`
But in the long run logging should be disabled
----
09.06.2020 Handling url path /watermarks
* gunicorn has to be started with argument `--env SCRIPT_NAME=/watermarks` which defines its path:
`gunicorn --env SCRIPT_NAME=/watermarks --workers 4 --bind unix:app.sock -m 007 app:app --log-level debug`
* allows for the following URLs
* http://127.0.0.1/watermarks
* http://127.0.0.1/watermarks/uploadbook
* http://127.0.0.1/watermarks/about
* added page /test `watermarks/test` for testing url_for() - correct
* made urls relative
* service file with `--env SCRIPT_NAME=/watermarks` see above
*

Binary file not shown.

@ -12,7 +12,7 @@
<dl>
<dt id="indexabout">ov73e3lxezo2klxva2frlzqbb2usiozqbe56xiochvz5lznpkk6kw4ad.onion</dt>
</dl>
<h1>404</h1>
<h1>TACTICAL WATERMARKS<br>ON TOR BROWSER!</h1>
</div>

@ -7,7 +7,7 @@
<div class="requestabook">
<h2>Books Requested</h2>
<p class="compressed"><a class="linktorequest" href="/request_form">Fill a form to request a book</a></p>
<p class="compressed"><a class="linktorequest" href="request_form">Fill a form to request a book</a></p>
{% for book in books %}
<div class="booksrequested">

@ -10,15 +10,15 @@
<div class="indextext">
<dl>
<dt id="indexabout"><a href="/about">About Tactical Watermarks</a></dt>
<dt id="indexabout"><a href="about">About Tactical Watermarks</a></dt>
</dl>
<h1>TACTICAL WATERMARKS</h1>
<dl>
<dt><a href="/uploadbook">De-watermark and republish a title</a></dt>
<dt><a href="/republish">Republish a new title</a></dt>
<dt><a href="/terms">Read Terms & Conditions</a></dt>
<dt><a href="uploadbook">De-watermark and republish a title</a></dt>
<dt><a href="republish">Republish a new title</a></dt>
<dt><a href="terms">Read Terms & Conditions</a></dt>
<dt><a href="ov73e3lxezo2klxva2frlzqbb2usiozqbe56xiochvz5lznpkk6kw4ad.onion">Link to Tor Browser</a></dt>
</dl>
</div>

@ -9,14 +9,14 @@
<div class="explainspace">
<p>Here you can upload a file that will be republished to Library Genesis. We take care of the whole process of republishing. Your book should not have watermarks. They will not be removed.</p>
<p class="secondp">We will also create a uploaders signature, read more about it <a href="/about">here</a>! Please feel free to leave your remarks on the process of sharing the file. If you want to batch upload, please <a href="mailto:pedrosacouto@protonmail.com">contact me</a> directly!</p>
<p class="secondp">We will also create a uploaders signature, read more about it <a href="about">here</a>! Please feel free to leave your remarks on the process of sharing the file. If you want to batch upload, please <a href="mailto:pedrosacouto@protonmail.com">contact me</a> directly!</p>
</div>
<form action="/uploadbook" method="POST" enctype="multipart/form-data">
<form action="uploadbook" method="POST" enctype="multipart/form-data">
<h3>UPLOAD THE FILE</h3>
<form action="/uploadbook" method="POST" enctype="multipart/form-data">
<form action="uploadbook" method="POST" enctype="multipart/form-data">
<div class="form-group">
<div class="custom-file">
<input oninput="filesize(this);" type="file" name="book" id="book">
@ -27,7 +27,7 @@
<h3>WATERMARK</h3>
<form action="/watermark" method="POST">
<form action="watermark" method="POST">
<div class="form-group">
<label>↘Identify yourself with a name, nickname or pseudonym!</label><br>
@ -69,7 +69,7 @@
<h2>Books Requested</h2>
<p class="compressed"><a class="linktorequest" href="/request_form">Fill a form to request a book</a></p>
<p class="compressed"><a class="linktorequest" href="request_form">Fill a form to request a book</a></p>
<div class="scrollrequests">
{% for book in books %}

@ -18,7 +18,7 @@
<div class="leftmarquee">
<div class="marquee">
<div class="track">
<div class="content"><a class="head" href="/">TACTICAL WATERMARKS TACTICAL WATERMARKS TACTICAL WATERMARKS TACTICAL WATERMARKS TACTICAL WATERMARKS TACTICAL WATERMARKS TACTICAL WATERMARKS TACTICAL WATERMARKS TACTICAL WATERMARKS TACTICAL WATERMARKS TACTICAL WATERMARKS TACTICAL WATERMARKS TACTICAL WATERMARKS TACTICAL WATERMARKS TACTICAL WATERMARKS TACTICAL WATERMARKS TACTICAL WATERMARKS TACTICAL WATERMARKS TACTICAL WATERMARKS TACTICAL WATERMARKS</a></div>
<div class="content"><a class="head" href="">TACTICAL WATERMARKS TACTICAL WATERMARKS TACTICAL WATERMARKS TACTICAL WATERMARKS TACTICAL WATERMARKS TACTICAL WATERMARKS TACTICAL WATERMARKS TACTICAL WATERMARKS TACTICAL WATERMARKS TACTICAL WATERMARKS TACTICAL WATERMARKS TACTICAL WATERMARKS TACTICAL WATERMARKS TACTICAL WATERMARKS TACTICAL WATERMARKS TACTICAL WATERMARKS TACTICAL WATERMARKS TACTICAL WATERMARKS TACTICAL WATERMARKS TACTICAL WATERMARKS</a></div>
</div>
</div>
</div>

@ -18,7 +18,7 @@
<div class="leftmarquee">
<div class="marquee">
<div class="track">
<div class="content"><a class="head" href="/">TACTICAL WATERMARKS TACTICAL WATERMARKS TACTICAL WATERMARKS TACTICAL WATERMARKS TACTICAL WATERMARKS TACTICAL WATERMARKS TACTICAL WATERMARKS TACTICAL WATERMARKS TACTICAL WATERMARKS TACTICAL WATERMARKS TACTICAL WATERMARKS TACTICAL WATERMARKS TACTICAL WATERMARKS TACTICAL WATERMARKS TACTICAL WATERMARKS TACTICAL WATERMARKS TACTICAL WATERMARKS TACTICAL WATERMARKS TACTICAL WATERMARKS TACTICAL WATERMARKS</a></div>
<div class="content"><a class="head" href="">TACTICAL WATERMARKS TACTICAL WATERMARKS TACTICAL WATERMARKS TACTICAL WATERMARKS TACTICAL WATERMARKS TACTICAL WATERMARKS TACTICAL WATERMARKS TACTICAL WATERMARKS TACTICAL WATERMARKS TACTICAL WATERMARKS TACTICAL WATERMARKS TACTICAL WATERMARKS TACTICAL WATERMARKS TACTICAL WATERMARKS TACTICAL WATERMARKS TACTICAL WATERMARKS TACTICAL WATERMARKS TACTICAL WATERMARKS TACTICAL WATERMARKS TACTICAL WATERMARKS</a></div>
</div>
</div>
</div>
@ -28,11 +28,11 @@
<h2>Sitemap</h2>
<br>
<ul>
<li><a class="mapping" href="/about">↘About Tactical Watermarks</a></li>
<li><a class="mapping" href="/uploadbook">↘De-watermark and republish</a></li>
<li><a class="mapping" href="/republish">↘Republish</a></li>
<li><a class="mapping" href="/terms">↘Read Terms & Conditions</a></li>
<li><a class="mapping" href="/404">↘Link to Tor Browser</a></li>
<li><a class="mapping" href="about">↘About Tactical Watermarks</a></li>
<li><a class="mapping" href="uploadbook">↘De-watermark and republish</a></li>
<li><a class="mapping" href="republish">↘Republish</a></li>
<li><a class="mapping" href="terms">↘Read Terms & Conditions</a></li>
<li><a class="mapping" href="404">↘Link to Tor Browser</a></li>
</ul>
</aside>

@ -18,7 +18,7 @@
<div class="scrollrequests">
<p class="compressed"><a class="linktorequest" href="/write_comment">Leave a comment</a>
<p class="compressed"><a class="linktorequest" href="write_comment">Leave a comment</a>
<div class="scrollrequests">
{% for comment in comments %}
<div class="booksrequested">

@ -9,10 +9,10 @@
<div class="explainspace">
<p>Here you can upload a watermarked file that will be republished to Library Genesis. I will de-watermark your text and take care of the whole process of republishing. All watermarks will be removed.</p>
<p class="secondp">We will also create a uploaders signature, read more about it <a href="/about">here</a>! Please feel free to leave your remarks on the process of sharing the file. If you want to batch upload, please <a href="mailto:pedrosacouto@protonmail.com">contact me</a> directly!</p>
<p class="secondp">We will also create a uploaders signature, read more about it <a href="about">here</a>! Please feel free to leave your remarks on the process of sharing the file. If you want to batch upload, please <a href="mailto:pedrosacouto@protonmail.com">contact me</a> directly!</p>
</div>
<form action="/uploadbook" method="POST" enctype="multipart/form-data">
<form action="uploadbook" method="POST" enctype="multipart/form-data">
<h3>UPLOAD THE FILE</h3>
@ -26,7 +26,7 @@
<h3>WATERMARK</h3>
<form action="/watermark" method="POST">
<form action="watermark" method="POST">
<div class="form-group">
<label>↘Identify yourself with a name, nickname or pseudonym!</label><br>
@ -68,7 +68,7 @@
<h2>Books Requested</h2>
<p class="compressed"><a class="linktorequest" href="/request_form">Fill a form to request a book</a></p>
<p class="compressed"><a class="linktorequest" href="request_form">Fill a form to request a book</a></p>
<div class="scrollrequests">
{% for book in books %}

@ -15,6 +15,15 @@ app.secret_key = 'PiracyIsCool'
now = datetime.datetime.now()
@app.route('/test', methods=['GET'])
def test():
index = url_for('index')
about = url_for('about')
links = f"<a href='{index}'>index</a><br/><a href='{about}'>about</a>"
return links
@app.route('/', methods=['GET'])
def index():
return render_template("public/index.html")
@ -25,9 +34,9 @@ def about():
# UPLOAD FILES
# THIS SHOULD BE IN CONFIG
app.config["BOOK_UPLOAD_DEWATERMARK"] = "/var/www/TacticalApp/app/static/dewatermark"
app.config["BOOK_UPLOAD_REPUBLISH"] = "/var/www/TacticalApp/app/static/republish"
app.config["BOOK_REQUEST"] = "/var/www/TacticalApp/app/static/request"
app.config["BOOK_UPLOAD_DEWATERMARK"] = "app/static/dewatermark"
app.config["BOOK_UPLOAD_REPUBLISH"] = "app/static/republish"
app.config["BOOK_REQUEST"] = "app/static/request"
app.config["ALLOWED_BOOK_EXTENSIONS"] = ["PDF", "EPUB"]
app.config["MAX_BOOK_FILESIZE"] = 500000000

Loading…
Cancel
Save