MicroPython stuff
This commit is contained in:
18
code/MicroPython/templates/index.html
Normal file
18
code/MicroPython/templates/index.html
Normal file
@@ -0,0 +1,18 @@
|
||||
{% args ram_free, ram_total %}
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>S2F Terminal</title>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<link href="/static/styles.css" rel="stylesheet">
|
||||
</head>
|
||||
<body>
|
||||
<h1>by Alexander Popov</h1>
|
||||
<p>Free RAM: {{ ram_free }} of {{ ram_total }}</p>
|
||||
<div>
|
||||
<a href="/?cmd=ftp">Поднять FTP сервер</a><br>
|
||||
<a href="/?cmd=reboot">Перезапустить</a><br>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
23
code/MicroPython/templates/index_html.py
Normal file
23
code/MicroPython/templates/index_html.py
Normal file
@@ -0,0 +1,23 @@
|
||||
# Autogenerated file
|
||||
def render(ram_free, ram_total):
|
||||
yield """<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>S2F Terminal</title>
|
||||
<meta charset=\"utf-8\">
|
||||
<meta name=\"viewport\" content=\"width=device-width,initial-scale=1\">
|
||||
<link href=\"/static/styles.css\" rel=\"stylesheet\">
|
||||
</head>
|
||||
<body>
|
||||
<h1>by Alexander Popov</h1>
|
||||
<p>Free RAM: """
|
||||
yield str(ram_free)
|
||||
yield """ of """
|
||||
yield str(ram_total)
|
||||
yield """</p>
|
||||
<div>
|
||||
<a href=\"/?cmd=ftp\">Поднять FTP сервер</a><br>
|
||||
<a href=\"/?cmd=reboot\">Перезапустить</a><br>
|
||||
</div>
|
||||
</body>
|
||||
</html>"""
|
||||
35
code/MicroPython/templates/upload.html
Normal file
35
code/MicroPython/templates/upload.html
Normal file
@@ -0,0 +1,35 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Microdot Upload Example</title>
|
||||
<meta charset="UTF-8">
|
||||
</head>
|
||||
<body>
|
||||
<h1>Microdot Upload Example</h1>
|
||||
<form id="form">
|
||||
<input type="file" id="file" name="file" />
|
||||
<input type="submit" value="Upload" />
|
||||
</form>
|
||||
<script>
|
||||
async function upload(ev) {
|
||||
ev.preventDefault();
|
||||
const file = document.getElementById('file').files[0];
|
||||
if (!file) {
|
||||
return;
|
||||
}
|
||||
await fetch('/upload', {
|
||||
method: 'POST',
|
||||
body: file,
|
||||
headers: {
|
||||
'Content-Type': 'application/octet-stream',
|
||||
'Content-Disposition': `attachment; filename="${file.name}"`,
|
||||
},
|
||||
}).then(res => {
|
||||
console.log('Upload accepted');
|
||||
window.location.href = '/';
|
||||
});
|
||||
}
|
||||
document.getElementById('form').addEventListener('submit', upload);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user