Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Fabian Anguiano
Fabian Anguiano

Posted on

How to run a internal Flask APK Server

Flask APK Server

Overview

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.

Features:

  • 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:

pythonfrom flask import Flask, send_fileimport osapp = Flask(__name__)@app.route('/apk')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')@app.route('/apk-test')def test_apk():    apk_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'app.apk')    try:        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.")@app.route('/test')def test_route():    return "Test route is working!"if __name__ == '__main__':    app.run(host='0.0.0.0', port=2000, debug=True)
Enter fullscreen modeExit fullscreen mode

Top comments(0)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

  • Joined

More fromFabian Anguiano

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp