syncing with web-ui

This commit is contained in:
Ace 2020-12-07 00:04:37 +01:00
parent 4dea07b1d1
commit 946ec7318e
3 changed files with 60 additions and 2 deletions

View File

@ -20,6 +20,11 @@ def index():
def wifi_setup():
return render_template('wifi.html', title='Wifi-setup')
# SSH file
@app.route('/create_ssh')
def create_ssh():
return render_template('create_ssh.html', title='SSH file generator')
# Inkycal-setup
@app.route('/inkycal-config-v2-0-0', methods=['GET', 'POST'])

View File

@ -31,11 +31,17 @@
</li>
<li class="nav-item">
<a class="nav-link" href="/inkycal-config-v2-0-0">Setup</a>
<a class="nav-link" href="/inkycal-config-v2-0-0">Create settings file</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/setup_wifi">WiFi-setup</a>
<a class="nav-link" href="/setup_wifi">Setup Wifi</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/create_ssh">Setup SSH</a>
</li>
</ul>
</div>
</div>

View File

@ -0,0 +1,47 @@
{% extends "base.html" %}
<!-- Main container -->
{% block content %}
<!-- Wrap everything in a container-->
<div class="container">
<!-- heading -->
<h3>SSH file generator</h3>
<!-- Instructions -->
<div class="alert alert-primary" role="alert">
<h4 class="alert-heading">Instructions</h4>
After flashing your microSD card with Raspberry Pi OS, click on Download SSH file. <br>
Place the generated file in the /BOOT folder to enable ssh.<br>
At the next boot, ssh will be enabled and this file will be deleted.
<hr>
You can now access the Raspberry Pi via it's IP address using a SSH Client of your choice.<br>
If you don't know the IP address, you can try using: raspberrypi.local<br>
</div>
<!-- Create a hidden div to prevent a fully empty file -->
<div id='ssh' hidden># nothing in here</div>
<div class="form-group">
<button type="button" class="btn btn-primary" onclick="getHTML('ssh.txt', 'ssh', 'text/plain')">Download SSH file</button>
</div>
<script>
function getHTML(filename, id, mimeType) {
var elHtml = document.getElementById(id).innerText;
if (navigator.msSaveBlob) {
navigator.msSaveBlob(new Blob([elHtml], { type: mimeType + ';charset=utf-8;' }), filename);
} else {
var link = document.createElement('a');
mimeType = mimeType || 'text/plain';
link.setAttribute('download', filename);
link.setAttribute('href', 'data:' + mimeType + ';charset=utf-8,' + encodeURIComponent(elHtml));
link.click();
}}
</script>
</div>
{% endblock %}