diff --git a/README.md b/README.md index 3750bf51..d2f10f54 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,11 @@ Node.js is a runtime environment that is used to run Javascript code and is need c. Check for **C:\Program Files\nodejs\\** in the list of paths that appear. If it's not there, click on New and add it to the list. Restart VSCode and it should work now. +#### Python +We need to download python locally to run our Flask server. +1. Please download Python here: https://www.python.org/downloads/. Be sure to download the correct installer as per your system (Windows/MacOS) +2. Run the Installer. + ## Repository To use git's version control, let's create and set up our repo :> @@ -88,13 +93,26 @@ cheatsheet: https://education.github.com/git-cheat-sheet-education.pdf [Some devices use **pip** while others use **pip3**. run ```pip --version``` or ```pip3 --version``` on a terminal to check which version you've got] Run these commands to set up your python virtual environment with necessary dependencies: + +First, go to the server directory. ```bash cd server +``` + +Next, create a virtual environment. This is always a goood practice when you run any Python project locally on your device. (This is not needed when running on Google Collab!) +```bash python -m venv venv +``` +Activate your virtual environment: +```bash # Windows users: .\venv\Scripts\activate # Mac/Linux users: source venv/bin/activate +``` + +Install all the python dependencies (like numpy, pandas, etc) +```bash pip install -r requirements.txt ``` diff --git a/frontend/pages/MLProjects/_components/analysis.js b/frontend/pages/MLProjects/_components/analysis.js index 07d469d1..29e4154f 100644 --- a/frontend/pages/MLProjects/_components/analysis.js +++ b/frontend/pages/MLProjects/_components/analysis.js @@ -8,7 +8,7 @@ dotenv.config(); const Analysis = () => { const [imageUrl, setImageUrl] = useState(''); - const local_server_endpoint = "https://aiscworkshop2024-production.up.railway.app" + const local_server_endpoint = "http://localhost:8080" // TODO useEffect(() => { const fetchImage = async () => { try { diff --git a/frontend/pages/MLProjects/_components/graph.js b/frontend/pages/MLProjects/_components/graph.js index 035d0c86..28e081be 100644 --- a/frontend/pages/MLProjects/_components/graph.js +++ b/frontend/pages/MLProjects/_components/graph.js @@ -6,7 +6,7 @@ import axios from "axios"; const Graph = () => { const [imageUrl, setImageUrl] = useState(''); - const local_server_endpoint = "https://aiscworkshop2024-production.up.railway.app" + const local_server_endpoint = "http://localhost:8080" // TODO useEffect(() => { const fetchImage = async () => { try { diff --git a/frontend/pages/MLProjects/_components/indexMSG.js b/frontend/pages/MLProjects/_components/indexMSG.js new file mode 100644 index 00000000..a1b602bb --- /dev/null +++ b/frontend/pages/MLProjects/_components/indexMSG.js @@ -0,0 +1,43 @@ +import { useEffect, useState } from "react"; +import axios from "axios"; + +// 'message': "Hello world!", +// 'people': ["Aa", "Bb", "Cc"] + + +const IndexMSG = () => { + const [msg, setMsg] = useState(null); + + console.log("HERE"); + useEffect(() => { + const fetchMsg = async () => { + try { + const res = await axios.get("http://localhost:8080"); + console.log("RES", res); + setMsg(res.data); + } catch (error) { + console.log(error); + } + } + fetchMsg(); + }, []); + + return ( +
+

DUMMY MESSAGE

+ {/* {msg ?

{msg}

:

LOADING...

} */} + {msg ? ( +
+

{msg.message}

+ {msg.people.map((person, index) => ( +

{person}

+ ))} +
+ ) : ( +

LOADING...

+ )} +
+ ) +} + +export default IndexMSG; \ No newline at end of file diff --git a/frontend/pages/MLProjects/_components/models.js b/frontend/pages/MLProjects/_components/models.js index a40107f2..197e8e3d 100644 --- a/frontend/pages/MLProjects/_components/models.js +++ b/frontend/pages/MLProjects/_components/models.js @@ -7,7 +7,7 @@ import axios from "axios"; const Models = ({ props }) => { // const [modelData, setModelData] = useState(null); const [modelData, setModelData] = useState(null); - const local_server_endpoint = "https://aiscworkshop2024-production.up.railway.app" + const local_server_endpoint = "http://localhost:8080" // TODO useEffect(() => { const fetchModelData = async () => { diff --git a/frontend/pages/about.js b/frontend/pages/about.js index 3e77332a..e69de29b 100644 --- a/frontend/pages/about.js +++ b/frontend/pages/about.js @@ -1,5 +0,0 @@ -export default function About() { - return( -
this is the About Page
- ) -} \ No newline at end of file diff --git a/frontend/pages/index.js b/frontend/pages/index.js index 73946b84..137c53bf 100644 --- a/frontend/pages/index.js +++ b/frontend/pages/index.js @@ -1,10 +1,9 @@ - - -export default function Home() { - return ( -
- this is hackdavis home page. - +import IndexMSG from "./MLProjects/_components/indexMSG" +export default function Home(){ + return( +
+

Hola

+
- ); -} + ) +} \ No newline at end of file diff --git a/server/LICENSE b/server/LICENSE new file mode 100644 index 00000000..7748ae08 --- /dev/null +++ b/server/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2023 Alphasec + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/server/Procfile b/server/Procfile new file mode 100644 index 00000000..199c836b --- /dev/null +++ b/server/Procfile @@ -0,0 +1 @@ +web: gunicorn --timeout 300 server:app diff --git a/server/analysis.png b/server/analysis.png deleted file mode 100644 index 48aa5e95..00000000 Binary files a/server/analysis.png and /dev/null differ diff --git a/server/eda.py b/server/eda.py index cc4115d7..0b5d351a 100644 --- a/server/eda.py +++ b/server/eda.py @@ -1,3 +1,4 @@ +# exploratory data analysis import pandas as pd import numpy as np import matplotlib.pyplot as plt diff --git a/server/first_graph.png b/server/first_graph.png index 93d6b204..f199661f 100644 Binary files a/server/first_graph.png and b/server/first_graph.png differ diff --git a/server/requirements.txt b/server/requirements.txt index 7f03480e..ea214cf8 100644 Binary files a/server/requirements.txt and b/server/requirements.txt differ diff --git a/server/vercel.json b/server/vercel.json new file mode 100644 index 00000000..1dff1d1f --- /dev/null +++ b/server/vercel.json @@ -0,0 +1,19 @@ +{ + "version": 2, + "builds": [ + { + "src": "main.py", + "use": "@vercel/python" + } + ], + "routes": [ + { + "src": "/(.*)", + "dest": "/main.py" + } + ], + "env": { + "FLASK_ENV": "production", + "FLASK_APP": "main.py" + } +}