jvrjsanchez / mockAI

https://mock-ai-eight.vercel.app
2 stars 2 forks source link

DB issues #9

Closed Tim-Quattrochi closed 5 months ago

Tim-Quattrochi commented 5 months ago

When am in the root directory of our project and run the command npm run flask-dev, it runs the script located in the package.json which is: "FLASK_DEBUG=1 pip3 install -r requirements.txt && python3 -m flask --app api/index run -p 3001 --reload".

Running this command, our endpoints that interact with the database do not work.

When I start the flask api while in the api directory with python3 index.py, the endpoints that interact with the database work.

Here is the response when I do a POST request to the add_email endpoint with npm run flask-dev :

Screenshot 2024-06-18 at 9 28 03 PM

I am assuming that when I run the app with the flask command, flask skips over the db import, because I also get this error in my terminal:

Screenshot 2024-06-18 at 9 30 37 PM

I want to solve this so that we don't have to change our start script, plus not sure if this would be an issue in production.

jvrjsanchez commented 5 months ago
Screenshot 2024-06-18 at 9 58 51 PM

I managed to get rid of the bug and gt the follwoing postman output

PNG image
Tim-Quattrochi commented 5 months ago
Screenshot 2024-06-18 at 9 58 51 PM

I managed to get rid of the bug and gt the follwoing postman output

PNG image

Awesome. I see you got a 404, in your local version, do you have the post route for add_email? If so, do you get the 404 on the health endpoint?

jvrjsanchez commented 5 months ago

Below we implemented the following changes to the index.py file:

if name == 'main': init_db() app.run(port=3001, debug=True)

we also fixed the postman output for the /api/add_email endpoint

Screenshot 2024-06-20 at 7 03 06 PM