Skip to content

Commit

Permalink
preliminary database setups
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan-Horng committed Nov 22, 2023
1 parent 8191202 commit 1f44652
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 0 deletions.
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)

0 comments on commit 1f44652

Please sign in to comment.