generated from nyu-software-engineering/containerized-app-exercise
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from software-students-fall2023/Andrew
microphone input
- Loading branch information
Showing
5 changed files
with
137 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,38 @@ | ||
"""Module designed to supplement front end webpage""" | ||
from flask import Flask, render_template, request, jsonify | ||
import os | ||
import datetime | ||
import sys | ||
from flask import ( | ||
Flask, | ||
render_template, | ||
request, | ||
redirect, | ||
url_for, | ||
make_response, | ||
session, | ||
) | ||
from pymongo import MongoClient | ||
import pymongo | ||
from bson.objectid import ObjectId | ||
import subprocess | ||
|
||
app = Flask("project4") | ||
app = Flask('project4') | ||
|
||
app.config['UPLOAD_FOLDER'] = 'uploads' | ||
os.makedirs(app.config['UPLOAD_FOLDER'], exist_ok=True) | ||
|
||
@app.route("/") | ||
def root_page(): | ||
"""Root page route""" | ||
return render_template("root.html") | ||
@app.route('/') | ||
def RootPage(): | ||
return render_template('root.html') | ||
|
||
@app.route('/analyzeData', methods=['POST']) | ||
def analyzeData(): | ||
try: | ||
if 'audio' not in request.files: | ||
return jsonify({"status": "error", "message": "No audio file provided"}) | ||
|
||
@app.route("/analyze_data", methods=["POST"]) | ||
def anaylze_data(): | ||
"""Analyze data by sending it to the ml client""" | ||
return | ||
audio_file = request.files['audio'] | ||
audio_path = os.path.join(app.config['UPLOAD_FOLDER'], 'user_audio.wav') | ||
audio_file.save(audio_path) | ||
|
||
|
||
print("Audio file saved at:", audio_path) | ||
result = subprocess.run(["C:\\Users\\Andrew - User\\AppData\\Local\\Microsoft\\WindowsApps\\python.exe", "E:\\4-containerized-app-exercise-rizzballs\\machine-learning-client\\machine_learning_client.py", audio_path], capture_output=True, text=True) | ||
|
||
|
||
return jsonify({"status": "success"}) | ||
|
||
except Exception as e: | ||
return jsonify({"status": "error", "message": str(e)}) | ||
|
||
|
||
if __name__ == "__main__": | ||
PORT = os.getenv("PORT", 5000) | ||
PORT = os.getenv('PORT', 5000) | ||
app.run(debug=True, port=PORT) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.