Google Gemini chat application Python-Flask, JavaScript This project is a chat application using Google Gemini API with a Flask back-end and a front-end built with HTML, CSS, and JavaScript.
Follow these steps to get the app running locally:
- Clone the repo Clone or download this repository to your local machine
git clone https://github.com/aryansnagar/gemini-chatbot.git
-
Env file Replace
1234with your Gemini-API key that you can get from Google AI Studio -
Set up Python environment and install dependencies
Open a terminal/command prompt in the project root folder and run the following commands
python -m venv .venv
.venv\Scripts\activate
pip install flask google-genai python-dotenv
- Run the Flask app
Start the Flask development server with
python main.py
- Open the app
Go tohttp://localhost:5000in your browser to use the chat app.
The frontend files are located in the templates and static folders:
templates/index.htmlContains the main HTML structure, including the message list and input field.static/css/style.cssCSS file to style the frontend interface.static/js/main.jsJavaScript file that handles sending messages to and receiving replies from the Flask backend.
Make sure in
index.htmlto reference CSS and JS as follows<link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}"> <script src="{{ url_for('static', filename='js/main.js') }}"></script>
main.pyThe Flask Python script that runs the backend server, exposes the/api/chatPOST endpoint, and communicates with the Gemini API..envContains your Gemini API key and any other environment variables.
With Love 💗 Aryan Nagar.