Simple Flask + Node.js web app setup for hackathons.
NvPmf/
├── app.py # Flask backend (Python)
├── index.html # Frontend (HTML/JS)
├── requirements.txt # Python dependencies
├── package.json # Node.js config (optional)
├── .env # API keys (NOT in git)
├── .env.example # Template for API keys
├── datasets/ # Put your datasets here
└── README.md # This file
pip install -r requirements.txt-
Create a
.envfile in thebackend/directory:cd backend # Create .env file
-
Edit
.envand add your Gemini API key:GEMINI_API_KEY=your-gemini-api-key-hereTo get a Gemini API key:
- Go to https://makersuite.google.com/app/apikey
- Sign in with your Google account
- Create a new API key
- Copy the key and paste it in your
.envfile
Put your dataset files in the datasets/ folder:
datasets/
├── data.csv
├── data.json
└── ...
Start Flask Backend:
python app.pyOpen Frontend:
- Open
index.htmlin your browser, OR - Use a simple server:
python -m http.server 8000then go tohttp://localhost:8000
-
Flask (Backend):
app.pyhandles API requests- Reads API keys from
.envfile - Serves data to frontend
- Can read datasets from
datasets/folder
- Reads API keys from
-
Frontend:
index.htmlis your web interface- Makes requests to Flask API
- Displays results
-
API Keys: Stored in
.env(never commit this file!)
In app.py:
@app.route('/api/your-endpoint', methods=['GET'])
def your_function():
# Use API_KEY here if needed
return jsonify({"data": "your data"})In app.py:
import pandas as pd # Add to requirements.txt: pandas==2.0.0
@app.route('/api/load-dataset', methods=['GET'])
def load_dataset():
df = pd.read_csv('datasets/your-data.csv')
return jsonify(df.to_dict())In app.py:
import requests # Add to requirements.txt: requests==2.31.0
@app.route('/api/external', methods=['GET'])
def call_external():
headers = {'Authorization': f'Bearer {API_KEY}'}
response = requests.get('https://api.example.com/data', headers=headers)
return jsonify(response.json())- ✅
.envis in.gitignore- your keys won't be committed - ✅ Never share your
.envfile - ✅ Use
.env.exampleas a template for teammates
- Flask: https://flask.palletsprojects.com/
- Python dotenv: Loads
.envfiles automatically - CORS: Allows frontend to call backend from different ports
Port 5000 already in use?
- Change
PORT=5001in.env
CORS errors?
- Make sure Flask-CORS is installed
- Check that
CORS(app)is inapp.py
Can't find API key?
- Make sure
.envfile exists - Check that variable name matches:
API_KEY=...