|
1 | 1 | const express = require("express"); |
| 2 | +const path = require('path'); |
2 | 3 | var nodemailer = require("nodemailer"); |
3 | 4 | require("dotenv").config(); |
4 | 5 | const { OpenAI } = require("openai"); |
@@ -47,22 +48,22 @@ app.get("/email", async (req, res) => { |
47 | 48 | }); |
48 | 49 | }); |
49 | 50 |
|
50 | | - |
51 | | - |
52 | 51 | app.get("/openai", async (req, res) => { |
53 | | - |
54 | | - const {recipe_country_of_origin, is_lactose_intolerant, is_vegan, what_are_user_other_dietary_requirements } = req.query |
| 52 | + const { |
| 53 | + recipe_country_of_origin, |
| 54 | + is_lactose_intolerant, |
| 55 | + is_vegan, |
| 56 | + what_are_user_other_dietary_requirements, |
| 57 | + } = req.query; |
55 | 58 | try { |
56 | 59 | console.log( |
57 | 60 | { recipe_country_of_origin }, |
58 | 61 | { is_lactose_intolerant }, |
59 | 62 | { is_vegan }, |
60 | | - {what_are_user_other_dietary_requirements} |
| 63 | + { what_are_user_other_dietary_requirements } |
61 | 64 | ); |
62 | 65 |
|
63 | | - const prompt = `Provide a recipe for a dish from ${ |
64 | | - recipe_country_of_origin |
65 | | - }, taking into account the fact that I'm ${ |
| 66 | + const prompt = `Provide a recipe for a dish from ${recipe_country_of_origin}, taking into account the fact that I'm ${ |
66 | 67 | is_lactose_intolerant === "true" |
67 | 68 | ? "lactose intolerant" |
68 | 69 | : "not lactose intolerant" |
@@ -105,15 +106,12 @@ app.get("/openai", async (req, res) => { |
105 | 106 | // const dishCountry = req.body.recipe_country_of_origin; |
106 | 107 | // const isUserLactoseIntolerant = req.body.is_lactose_intolerant; |
107 | 108 |
|
108 | | - |
109 | 109 | // res.json({ |
110 | 110 | // message: `Variables ${dishCountry} and ${isUserLactoseIntolerant} received successfully`, |
111 | 111 | // }); |
112 | 112 | // }); |
113 | 113 |
|
114 | | - |
115 | | - |
116 | | -app.use(express.static("public")); |
| 114 | +app.use(express.static(path.join(__dirname, "public"))); |
117 | 115 | const port = process.env.PORT || 3000; |
118 | 116 | app.listen(port, () => { |
119 | 117 | console.log(`Server running on port ${port}`); |
|
0 commit comments