This project is an auto-updating Flask webserver designed to streamline the deployment and development process. It is compatible with Debian/Ubuntu for production and Windows for development purposes.
- Automatically updates itself with the latest changes from the repository.
- Designed for easy deployment and development.
- Supports a branching workflow for better version control.
- Ensure you have Python 3.x installed on your system.
- Install
pip(Python package manager) if not already installed. - For production, use a Debian/Ubuntu-based system. For development, use Windows.
-
Fork the Repository
Start by forking this repository to create your own version for your webserver. This allows you to customize and manage your own updates. -
Clone the Repository
Clone your forked repository to your local machine:git clone https://github.com/<your-username>/Auto-Updateable-Flask-webserver.git cd Auto-Updateable-Flask-webserver
-
Branching Workflow
Use a two-branch workflow:main: For production-ready code.dev: For development and testing new features.
Create the
devbranch if it doesn't already exist:git checkout -b dev
-
Install Dependencies
Install the required Python packages:pip install -r requirements.txt
-
Environment Configuration
Configure the .env with your variables. (Note: Remember to add the .env to the .gitignore file) -
Run the Application
Start the Flask webserver: run the start.bat in/src/backend/start/start.bat
To deploy the auto-updating Flask webserver in a production environment, follow these steps:
-
Use a Debian/Ubuntu Server
Ensure that you have a production server is running a Debian or Ubuntu-based operating system. -
Configure
systemdfor Automatic Startup
Use the providedautowebserver.servicetemplate located in/src/autowebserver.serviceto configuresystemd. This will ensure that the webserver starts automatically on system boot.- Copy the service file to the
/etc/systemd/system/directory:sudo cp /src/autowebserver.service /etc/systemd/system/
- Reload the
systemddaemon to recognize the new service:sudo systemctl daemon-reload
- Enable and start the service:
sudo systemctl enable autowebserver sudo systemctl start autowebserver
- Copy the service file to the
-
Set Up a Reverse Proxy
Configure a reverse proxy to handle incoming HTTP/HTTPS requests and forward them to the Flask webserver. You can use tools like Nginx or a Cloudflare Tunnel for this purpose.- For Nginx, create a configuration file for your domain and set it to forward requests to the Flask server's port (e.g.,
http://127.0.0.1:5000). - For Cloudflare Tunnel, follow their documentation to create a secure tunnel to your server.
- For Nginx, create a configuration file for your domain and set it to forward requests to the Flask server's port (e.g.,
-
Configure a GitHub Webhook for Automatic Updates
Set up a GitHub webhook to trigger the webserver's update mechanism whenever changes are pushed to the repository.- Go to your repository on GitHub and navigate to Settings > Webhooks.
- Click Add webhook and set the following:
- Payload URL:
https://<your_domain>/webhook - Content type:
application/x-www-form-urlencoded - Secret: Use a secure secret key and configure it in your
.envfile.
- Payload URL:
- Select the events you want to trigger the webhook (e.g.,
Push events). - Save the webhook configuration.
By following these steps, your Flask webserver will be ready for production deployment with automatic updates and robust request handling.
src/update.shsrc/start/start.sh.env.gitignore
This project is licensed under the MIT License. See the LICENSE file for details.