Simple Flask app that fetches news from NewsAPI and optionally checks authenticity via GROQ AI.
Setup
- Create a virtual environment and install dependencies:
python -m venv venv
venv\Scripts\Activate.ps1
pip install -r requirements.txt-
Copy
.env.exampleto.envand setNEWS_API_KEY(required) andGROQ_API_KEY(optional). -
Run the app in development:
python web.pyDeploy the Flask app
This repository is ready to deploy on Render from GitHub.
- Push the latest code to GitHub.
- In Render, create a new
Web Servicefrom this repository. - Render will detect
render.yamland use:- build command:
pip install -r requirements.txt - start command:
gunicorn wsgi:app
- build command:
- Add these environment variables in Render:
NEWS_API_KEYrequiredGROQ_API_KEYoptional
- After deploy, Render will give you a public HTTPS URL such as
https://your-news-app.onrender.com.
Use the Android app on any network
Once the Flask app is hosted, open the Android app and set the server URL to your public Render URL, for example:
https://your-news-app.onrender.com/
That URL will work from any network because the backend is no longer running only on your local Wi-Fi.
Deploy with Firebase
Firebase Hosting alone cannot run this Flask backend. For Firebase, use Firebase Hosting in front of Cloud Run.
This repository now includes a Dockerfile for Cloud Run.
Typical Firebase path:
- Create a Firebase project.
- Deploy this Flask app to Cloud Run from the repo or from local source.
- In Firebase Hosting, connect your site to the Cloud Run service.
- Put the final public HTTPS URL into the Android app.
At a high level, the Firebase docs for this setup are:
- Firebase Hosting with Cloud Run
- Cloud Run Python/Flask deployment
Once the app is live on Firebase/Cloud Run, use the hosted HTTPS URL in the APK instead of a local Wi-Fi IP.
Build a Windows .exe
-
Make sure your
.envfile is present in the project folder. -
Run the build script:
.\build_exe.ps1-
After the build finishes, your executable will be at
dist\NewsApp.exe. -
Keep a copy of
.envnext toNewsApp.exeso the app can read your API keys after packaging.
Notes
- The packaged app starts a local Flask server and opens your browser automatically.
- If
GROQ_API_KEYis missing, authenticity checks are disabled and the app will still work. - Keep your API keys private and do not commit
.envto source control.