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.
- Loading branch information
1 parent
8191202
commit 1f44652
Showing
3 changed files
with
59 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import os | ||
|
||
from pymongo import MongoClient | ||
from dotenv import load_dotenv | ||
|
||
load_dotenv() | ||
|
||
# Create a new client and connect to the server | ||
uri = os.getenv("MONGODB_URI").format( | ||
os.getenv("MONGODB_USER"), os.getenv("MONGODB_PASSWORD") | ||
) | ||
client = MongoClient(uri, serverSelectionTimeoutMS=3000) | ||
DB = None | ||
|
||
# Send a ping to confirm a successful connection | ||
try: | ||
client.admin.command("ping") | ||
DB = client[os.getenv("MONGODB_DATABASE")] | ||
print("Pinged your deployment. You successfully connected to MongoDB!") | ||
except Exception as e: # pylint: disable=broad-except | ||
print(e) |
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
FROM python:3.11 | ||
|
||
WORKDIR /app | ||
|
||
COPY Pipfile Pipfile.lock ./ | ||
|
||
RUN pip install pipenv && pipenv install --deploy --ignore-pipfile | ||
RUN apt-get -y update | ||
RUN apt-get -y install libasound-dev | ||
RUN apt-get -y install portaudio19-dev | ||
|
||
WORKDIR /usr/src/app | ||
COPY requirements.txt ./ | ||
|
||
COPY . . | ||
|
||
RUN pip install -r requirements.txt | ||
|
||
CMD ["pipenv", "run", "python", "machine_learning_client.py"] |
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from flask import Flask, render_template, request, redirect, url_for, make_response, session | ||
import os | ||
from pymongo import MongoClient | ||
import pymongo | ||
import datetime | ||
from bson.objectid import ObjectId | ||
import sys | ||
|
||
app = Flask('project4') | ||
|
||
@app.route("/process_wav", methods=['GET', 'POST']) | ||
def process_wav(): | ||
if request.method == 'POST': | ||
audio_file = request.form.get("audio-recording") | ||
dir = 'audio/'+str(audio_file) | ||
|
||
if __name__ == "__main__": | ||
PORT = os.getenv('PORT', 5000) | ||
app.run(debug=True,port=PORT) |