Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,50 +1,48 @@
|
|
| 1 |
-
import
|
| 2 |
import subprocess
|
| 3 |
import os
|
| 4 |
import shutil
|
| 5 |
|
| 6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
try:
|
| 8 |
-
#
|
| 9 |
-
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
-
#
|
| 12 |
-
|
| 13 |
-
|
| 14 |
|
| 15 |
-
#
|
| 16 |
command = [
|
| 17 |
"docker", "run", "--rm",
|
| 18 |
"-v", f"{app_icon_path}:/app/icon.png", # Mount the app icon to the container
|
| 19 |
-
"-v", f"{os.getcwd()}/output:/app/output", # Mount
|
| 20 |
-
"ios-ipa-builder", #
|
| 21 |
app_name, bundle_id, website_url
|
| 22 |
]
|
| 23 |
|
| 24 |
# Run the docker command to build the IPA
|
| 25 |
result = subprocess.run(command, capture_output=True, text=True)
|
| 26 |
|
| 27 |
-
# Check the result
|
| 28 |
if result.returncode == 0:
|
| 29 |
-
ipa_path = "/app/output/your_ipa_file.ipa" #
|
| 30 |
-
return
|
| 31 |
else:
|
| 32 |
-
return
|
| 33 |
-
|
| 34 |
except Exception as e:
|
| 35 |
-
return
|
| 36 |
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
fn=generate_ipa,
|
| 40 |
-
inputs=[
|
| 41 |
-
gr.Textbox(label="App Name"),
|
| 42 |
-
gr.Textbox(label="Bundle ID"),
|
| 43 |
-
gr.Textbox(label="Website URL"),
|
| 44 |
-
gr.File(label="App Icon (PNG)"),
|
| 45 |
-
],
|
| 46 |
-
outputs=gr.Textbox(label="Build Status"),
|
| 47 |
-
)
|
| 48 |
|
| 49 |
-
iface.launch()
|
| 50 |
|
|
|
|
| 1 |
+
from flask import Flask, request, jsonify
|
| 2 |
import subprocess
|
| 3 |
import os
|
| 4 |
import shutil
|
| 5 |
|
| 6 |
+
app = Flask(__name__)
|
| 7 |
+
|
| 8 |
+
# Ensure the output directory exists
|
| 9 |
+
os.makedirs('./output', exist_ok=True)
|
| 10 |
+
|
| 11 |
+
@app.route('/upload', methods=['POST'])
|
| 12 |
+
def upload():
|
| 13 |
try:
|
| 14 |
+
# Get form data
|
| 15 |
+
app_name = request.form['appName']
|
| 16 |
+
bundle_id = request.form['bundleId']
|
| 17 |
+
website_url = request.form['websiteUrl']
|
| 18 |
+
icon_file = request.files['icon']
|
| 19 |
|
| 20 |
+
# Save the app icon to a temporary file
|
| 21 |
+
app_icon_path = os.path.join("/tmp", icon_file.filename)
|
| 22 |
+
icon_file.save(app_icon_path)
|
| 23 |
|
| 24 |
+
# Docker command to run the IPA builder
|
| 25 |
command = [
|
| 26 |
"docker", "run", "--rm",
|
| 27 |
"-v", f"{app_icon_path}:/app/icon.png", # Mount the app icon to the container
|
| 28 |
+
"-v", f"{os.getcwd()}/output:/app/output", # Mount the output folder
|
| 29 |
+
"ios-ipa-builder", # Docker image name
|
| 30 |
app_name, bundle_id, website_url
|
| 31 |
]
|
| 32 |
|
| 33 |
# Run the docker command to build the IPA
|
| 34 |
result = subprocess.run(command, capture_output=True, text=True)
|
| 35 |
|
|
|
|
| 36 |
if result.returncode == 0:
|
| 37 |
+
ipa_path = "/app/output/your_ipa_file.ipa" # Change this based on your output path
|
| 38 |
+
return jsonify({"status": "success", "ipa_url": ipa_path}), 200
|
| 39 |
else:
|
| 40 |
+
return jsonify({"status": "error", "message": result.stderr}), 500
|
| 41 |
+
|
| 42 |
except Exception as e:
|
| 43 |
+
return jsonify({"status": "error", "message": str(e)}), 500
|
| 44 |
|
| 45 |
+
if __name__ == "__main__":
|
| 46 |
+
app.run(debug=True, host='0.0.0.0', port=5000)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
|
|
|
|
| 48 |
|