DEV Community

Fabian Anguiano
Fabian Anguiano

Posted on

How to run a internal Flask APK Server

Flask APK Server


This Flask application serves an APK file to clients. Developed as a minimalistic solution, the app is designed to be used in a controlled environment with a limited number of users.


  • Simple endpoint (/apk) to download the APK.
  • Endpoint (/test) to test the server's functionality.
  • Endpoint (/apk-test) to check the presence and size of the APK file.

Flask App:

from flask import Flask, send_file
import os

app = Flask(__name__)

def download_apk():
    apk_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'app.apk')
    return send_file(apk_path, as_attachment=True, download_name='app.apk')

def test_apk():
    apk_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'app.apk')
        size = os.path.getsize(apk_path)
        return jsonify(status="success", message=f"The APK exists and its size is {size} bytes")
    except OSError:
        return jsonify(status="error", message="The APK does not exist or there's a problem accessing it.")

def test_route():
    return "Test route is working!"

if __name__ == '__main__':'', port=2000, debug=True)
Enter fullscreen mode Exit fullscreen mode

Top comments (0)