Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

preliminary database setups #4

Merged
merged 1 commit into from
Nov 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions database/database.py.py
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)
19 changes: 19 additions & 0 deletions machine-learning-client/Dockerfile.txt
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"]
19 changes: 19 additions & 0 deletions machine-learning-client/machine_learning_client.py
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)
Loading