added upload and messages
parent
83dc392cac
commit
389f9b71cb
@ -0,0 +1,7 @@
|
||||
FROM tiangolo/uwsgi-nginx-flask:python3.8-alpine
|
||||
RUN apk --update add bash nano
|
||||
ENV STATIC_URL /static
|
||||
ENV STATIC_PATH /var/www/app/static
|
||||
COPY ./requirements.txt /var/www/requirements.txt
|
||||
RUN pip install -r /var/www/requirements.txt
|
||||
|
Binary file not shown.
@ -0,0 +1,12 @@
|
||||
{% macro render_field(field) %}
|
||||
<dt>{{ field.label }}
|
||||
<dd>{{ field(**kwargs)|safe }}
|
||||
{% if field.errors %}
|
||||
<ul class=errors>
|
||||
{% for error in field.errors %}
|
||||
<li>{{ error }}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
</dd>
|
||||
{% endmacro %}
|
@ -0,0 +1,108 @@
|
||||
{% extends 'base.html' %}
|
||||
|
||||
{% block main %}
|
||||
{% from "_formhelpers.html" import render_field %}
|
||||
|
||||
<h1 class="page-header">Add Message</h1>
|
||||
{% with messages = get_flashed_messages() %}
|
||||
{% if messages %}
|
||||
<div class="alert alert-danger">
|
||||
<ul>
|
||||
{% for message in messages %}
|
||||
<li>{{ message }}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
|
||||
<form method="POST" action="{{ url_for('addaudio') }}" enctype=multipart/form-data>
|
||||
{{ form.csrf_token }}
|
||||
<input type="hidden" name="longitude" value="{{ longitude }}" />
|
||||
<input type="hidden" name="latitude" value="{{ latitude }}" />
|
||||
<div style="width: 40%;">
|
||||
message: {{ form.message(cols="45", rows="10", class="form-control") }}
|
||||
</div>
|
||||
|
||||
<div id="audio">
|
||||
<a onclick="record_audio()" href="#">record</a>
|
||||
<a onclick="stop_audio()" href="#">stop</a>
|
||||
<span id="seconds_rec"></span><span> seconds</span>
|
||||
<div id="audio-player-container"></div>
|
||||
</div>
|
||||
|
||||
<input type="file" name="file" id="uploadedFile" accept="audio/*"><br>
|
||||
|
||||
<button type="submit">Submit</button>
|
||||
|
||||
|
||||
|
||||
</form>
|
||||
|
||||
<clear>
|
||||
{% endblock main %}
|
||||
{% block js%}
|
||||
|
||||
<script>
|
||||
|
||||
var mediaRecorder;
|
||||
var seconds_rec = 0;
|
||||
var seconds_int;
|
||||
|
||||
function record_audio(){
|
||||
seconds_int = setInterval(
|
||||
function () {
|
||||
document.getElementById("seconds_rec").innerHTML = seconds_rec;
|
||||
seconds_rec += 1;
|
||||
}, 1000);
|
||||
|
||||
navigator.mediaDevices.getUserMedia({ audio: true })
|
||||
.then(stream => {
|
||||
mediaRecorder = new MediaRecorder(stream);
|
||||
mediaRecorder.start();
|
||||
|
||||
const audioChunks = [];
|
||||
mediaRecorder.addEventListener("dataavailable", event => {
|
||||
audioChunks.push(event.data);
|
||||
});
|
||||
|
||||
mediaRecorder.addEventListener("stop", () => {
|
||||
const audioBlob = new Blob(audioChunks);
|
||||
const audioUrl = URL.createObjectURL(audioBlob);
|
||||
var sound = document.createElement('audio');
|
||||
sound.id = 'audio-player';
|
||||
sound.controls = 'controls';
|
||||
sound.src = audioUrl;
|
||||
console.log(audioUrl)
|
||||
sound.type = 'audio/ogg';
|
||||
document.getElementById("audio-player-container").innerHTML = sound.outerHTML;
|
||||
|
||||
|
||||
const audio = new Audio(audioUrl);
|
||||
//audio.play();
|
||||
let file = new File([audioBlob], "audio.ogg",{type:"audio/ogg"});
|
||||
let container = new DataTransfer();
|
||||
container.items.add(file);
|
||||
document.getElementById("uploadedFile").files = container.files;
|
||||
|
||||
//const audio = new Audio(audioUrl);
|
||||
//audio.play();
|
||||
});
|
||||
|
||||
setTimeout(() => {
|
||||
stop_audio()
|
||||
}, 1000 * 60);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function stop_audio(){
|
||||
clearInterval(seconds_int);
|
||||
mediaRecorder.stop();
|
||||
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
{% endblock js%}
|
@ -0,0 +1,33 @@
|
||||
{% extends 'base.html' %}
|
||||
|
||||
{% block main %}
|
||||
{% from "_formhelpers.html" import render_field %}
|
||||
|
||||
<h1 class="page-header">Add Message</h1>
|
||||
{% with messages = get_flashed_messages() %}
|
||||
{% if messages %}
|
||||
<div class="alert alert-danger">
|
||||
<ul>
|
||||
{% for message in messages %}
|
||||
<li>{{ message }}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
<form method="POST" action="{{ url_for('addtext') }}" enctype=multipart/form-data>
|
||||
{{ form.csrf_token }}
|
||||
<input type="hidden" name="longitude" value="{{ longitude }}" />
|
||||
<input type="hidden" name="latitude" value="{{ latitude }}" />
|
||||
<div style="width: 40%;">
|
||||
message: {{ form.message(cols="45", rows="10", class="form-control") }}
|
||||
</div>
|
||||
|
||||
<button type="submit">Submit</button>
|
||||
|
||||
|
||||
</form>
|
||||
|
||||
<clear>
|
||||
{% endblock main %}
|
||||
|
@ -0,0 +1,13 @@
|
||||
click==8.1.3
|
||||
Flask==2.2.2
|
||||
Flask_SocketIO==5.3.1
|
||||
flask_sqlalchemy==3.0.2
|
||||
Flask_WTF==1.0.1
|
||||
marshmallow==3.18.0
|
||||
PyPDF2==2.11.1
|
||||
python-dotenv==0.21.0
|
||||
requests==2.28.1
|
||||
SQLAlchemy==1.4.42
|
||||
Wand==0.6.10
|
||||
Werkzeug==2.2.2
|
||||
WTForms==3.0.1
|
@ -1,3 +1,3 @@
|
||||
#! /usr/bin/env python
|
||||
from app import app, socketio
|
||||
socketio.run(app,host="0.0.0.0", port=8080, ssl_context='adhoc')
|
||||
socketio.run(app,host="0.0.0.0", port=8080)
|
||||
|
@ -0,0 +1,6 @@
|
||||
#!/bin/bash
|
||||
app="geo.app"
|
||||
docker build -t ${app} .
|
||||
docker run --platform linux/amd64 -p 56733:80 \
|
||||
--name=${app} \
|
||||
-v $PWD:/app ${app}
|
Loading…
Reference in New Issue