In receive mode, allow uploader to close the server when they are done

This commit is contained in:
Micah Lee 2018-03-14 08:16:09 -07:00
parent 0b10e71547
commit 01f86daf8f
No known key found for this signature in database
GPG key ID: 403C2657CD994F73
3 changed files with 36 additions and 13 deletions

View file

@ -305,9 +305,7 @@ class Web(object):
valid = True
self.common.log('Web', 'receive_routes', '/upload, uploaded {}, saving to {}'.format(f.filename, local_path))
print('')
print(strings._('receive_mode_received_file').format(local_path))
print('')
f.save(local_path)
# Note that flash strings are on English, and not translated, on purpose,
@ -319,6 +317,12 @@ class Web(object):
return redirect('/{}'.format(slug_candidate))
@self.app.route("/<slug_candidate>/close", methods=['POST'])
def close(slug_candidate):
self.check_slug_candidate(slug_candidate)
self.force_shutdown()
return ""
def common_routes(self):
"""
Common web app routes between sending and receiving

View file

@ -56,6 +56,20 @@ header .right ul li {
cursor: pointer;
}
.close-button {
color: #ffffff;
background-color: #c90c0c;
padding: 10px;
border: 0;
border-radius: 5px;
text-decoration: none;
margin-left: 1rem;
cursor: pointer;
position: absolute;
right: 10px;
bottom: 10px;
}
table.file-list {
width: 100%;
margin: 0 auto;

View file

@ -12,16 +12,6 @@
<h1>OnionShare</h1>
</header>
{% with messages = get_flashed_messages() %}
{% if messages %}
<ul class=flashes>
{% for message in messages %}
<li>{{ message }}</li>
{% endfor %}
</ul>
{% endif %}
{% endwith %}
<div class="upload-wrapper">
<div class="upload">
<p><img class="logo" src="/static/img/logo_large.png" title="OnionShare"></p>
@ -29,10 +19,25 @@
<p class="upload-description">Select the files you want to send, then click "Send Files"...</p>
<form method="post" enctype="multipart/form-data" action="/{{ slug }}/upload">
<p><input type="file" name="file[]" multiple /></p>
<p><input type="submit" class="button" value="Upload Files" /></p>
<p><input type="submit" name="upload" class="button" value="Upload Files" /></p>
<div>
{% with messages = get_flashed_messages() %}
{% if messages %}
<ul class=flashes>
{% for message in messages %}
<li>{{ message }}</li>
{% endfor %}
</ul>
{% endif %}
{% endwith %}
</div>
</form>
</div>
</div>
<form method="post" action="/{{ slug }}/close">
<input type="submit" name="close" class="close-button" value="I'm Finished Uploading" />
</form>
</body>
</html>