apkweb 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- apkweb-0.1.0/LICENSE +21 -0
- apkweb-0.1.0/PKG-INFO +45 -0
- apkweb-0.1.0/README.md +27 -0
- apkweb-0.1.0/apkweb.egg-info/PKG-INFO +45 -0
- apkweb-0.1.0/apkweb.egg-info/SOURCES.txt +9 -0
- apkweb-0.1.0/apkweb.egg-info/dependency_links.txt +1 -0
- apkweb-0.1.0/apkweb.egg-info/requires.txt +2 -0
- apkweb-0.1.0/apkweb.egg-info/top_level.txt +1 -0
- apkweb-0.1.0/apkweb.py +174 -0
- apkweb-0.1.0/pyproject.toml +23 -0
- apkweb-0.1.0/setup.cfg +4 -0
apkweb-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 e5310012
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
apkweb-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: apkweb
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Run an Android APK in your browser in two lines of Python (via adb).
|
|
5
|
+
Author: e5310012
|
|
6
|
+
License: MIT
|
|
7
|
+
Keywords: apk,android,emulator,adb,browser,web
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Classifier: Topic :: Software Development :: Testing
|
|
12
|
+
Requires-Python: >=3.8
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
License-File: LICENSE
|
|
15
|
+
Requires-Dist: flask
|
|
16
|
+
Requires-Dist: pyaxmlparser
|
|
17
|
+
Dynamic: license-file
|
|
18
|
+
|
|
19
|
+
# apkweb
|
|
20
|
+
|
|
21
|
+
Run an Android APK in your browser with two lines of Python.
|
|
22
|
+
|
|
23
|
+
```python
|
|
24
|
+
import apkweb
|
|
25
|
+
apkweb.run("app.apk", template="phone", background="ocean")
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Requirements
|
|
29
|
+
- `pip install apkweb`
|
|
30
|
+
- `adb` (Android platform-tools) in your PATH
|
|
31
|
+
- A running Android backend: a real phone over USB, Waydroid, redroid, or BlueStacks (`adb connect`)
|
|
32
|
+
|
|
33
|
+
## Options
|
|
34
|
+
| Option | Values |
|
|
35
|
+
|---|---|
|
|
36
|
+
| `template` | `phone`, `tablet`, `minimal`, `retro`, `none` |
|
|
37
|
+
| `background` | `dark`, `light`, `sunset`, `ocean`, `purple`, or any CSS value |
|
|
38
|
+
| `device` | adb serial, e.g. `"127.0.0.1:5555"` |
|
|
39
|
+
| `port` | default `5000` |
|
|
40
|
+
|
|
41
|
+
The page streams the device screen and supports tap, swipe, Back/Home/Recent and text input.
|
|
42
|
+
For local use only: the server has no authentication, so do not expose it publicly.
|
|
43
|
+
|
|
44
|
+
## License
|
|
45
|
+
MIT
|
apkweb-0.1.0/README.md
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# apkweb
|
|
2
|
+
|
|
3
|
+
Run an Android APK in your browser with two lines of Python.
|
|
4
|
+
|
|
5
|
+
```python
|
|
6
|
+
import apkweb
|
|
7
|
+
apkweb.run("app.apk", template="phone", background="ocean")
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
## Requirements
|
|
11
|
+
- `pip install apkweb`
|
|
12
|
+
- `adb` (Android platform-tools) in your PATH
|
|
13
|
+
- A running Android backend: a real phone over USB, Waydroid, redroid, or BlueStacks (`adb connect`)
|
|
14
|
+
|
|
15
|
+
## Options
|
|
16
|
+
| Option | Values |
|
|
17
|
+
|---|---|
|
|
18
|
+
| `template` | `phone`, `tablet`, `minimal`, `retro`, `none` |
|
|
19
|
+
| `background` | `dark`, `light`, `sunset`, `ocean`, `purple`, or any CSS value |
|
|
20
|
+
| `device` | adb serial, e.g. `"127.0.0.1:5555"` |
|
|
21
|
+
| `port` | default `5000` |
|
|
22
|
+
|
|
23
|
+
The page streams the device screen and supports tap, swipe, Back/Home/Recent and text input.
|
|
24
|
+
For local use only: the server has no authentication, so do not expose it publicly.
|
|
25
|
+
|
|
26
|
+
## License
|
|
27
|
+
MIT
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: apkweb
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Run an Android APK in your browser in two lines of Python (via adb).
|
|
5
|
+
Author: e5310012
|
|
6
|
+
License: MIT
|
|
7
|
+
Keywords: apk,android,emulator,adb,browser,web
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Classifier: Topic :: Software Development :: Testing
|
|
12
|
+
Requires-Python: >=3.8
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
License-File: LICENSE
|
|
15
|
+
Requires-Dist: flask
|
|
16
|
+
Requires-Dist: pyaxmlparser
|
|
17
|
+
Dynamic: license-file
|
|
18
|
+
|
|
19
|
+
# apkweb
|
|
20
|
+
|
|
21
|
+
Run an Android APK in your browser with two lines of Python.
|
|
22
|
+
|
|
23
|
+
```python
|
|
24
|
+
import apkweb
|
|
25
|
+
apkweb.run("app.apk", template="phone", background="ocean")
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Requirements
|
|
29
|
+
- `pip install apkweb`
|
|
30
|
+
- `adb` (Android platform-tools) in your PATH
|
|
31
|
+
- A running Android backend: a real phone over USB, Waydroid, redroid, or BlueStacks (`adb connect`)
|
|
32
|
+
|
|
33
|
+
## Options
|
|
34
|
+
| Option | Values |
|
|
35
|
+
|---|---|
|
|
36
|
+
| `template` | `phone`, `tablet`, `minimal`, `retro`, `none` |
|
|
37
|
+
| `background` | `dark`, `light`, `sunset`, `ocean`, `purple`, or any CSS value |
|
|
38
|
+
| `device` | adb serial, e.g. `"127.0.0.1:5555"` |
|
|
39
|
+
| `port` | default `5000` |
|
|
40
|
+
|
|
41
|
+
The page streams the device screen and supports tap, swipe, Back/Home/Recent and text input.
|
|
42
|
+
For local use only: the server has no authentication, so do not expose it publicly.
|
|
43
|
+
|
|
44
|
+
## License
|
|
45
|
+
MIT
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
apkweb
|
apkweb-0.1.0/apkweb.py
ADDED
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
"""
|
|
2
|
+
apkweb - شغّل APK في المتصفح بسطرين.
|
|
3
|
+
|
|
4
|
+
import apkweb
|
|
5
|
+
apkweb.run("app.apk", template="phone", background="dark")
|
|
6
|
+
|
|
7
|
+
المتطلبات:
|
|
8
|
+
pip install flask pyaxmlparser
|
|
9
|
+
adb (platform-tools) في الـ PATH
|
|
10
|
+
جهاز أندرويد شغّال: موبايل بكابل / Waydroid / redroid / BlueStacks (adb connect)
|
|
11
|
+
"""
|
|
12
|
+
import shutil
|
|
13
|
+
import subprocess
|
|
14
|
+
import threading
|
|
15
|
+
import webbrowser
|
|
16
|
+
|
|
17
|
+
from flask import Flask, Response, request
|
|
18
|
+
|
|
19
|
+
# ---------- القوالب (شكل الإطار حوالين الشاشة) ----------
|
|
20
|
+
TEMPLATES = {
|
|
21
|
+
"phone": "border:14px solid #111;border-radius:44px;box-shadow:0 25px 60px #0009;",
|
|
22
|
+
"tablet": "border:20px solid #222;border-radius:26px;box-shadow:0 25px 60px #0009;",
|
|
23
|
+
"minimal": "border-radius:12px;box-shadow:0 8px 30px #0005;",
|
|
24
|
+
"retro": "border:6px solid #0f0;border-radius:4px;box-shadow:0 0 35px #0f06;",
|
|
25
|
+
"none": "",
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
# ---------- الخلفيات ----------
|
|
29
|
+
BACKGROUNDS = {
|
|
30
|
+
"dark": "#12141a",
|
|
31
|
+
"light": "#eef1f6",
|
|
32
|
+
"sunset": "linear-gradient(135deg,#ff7e5f,#feb47b)",
|
|
33
|
+
"ocean": "linear-gradient(135deg,#2193b0,#6dd5ed)",
|
|
34
|
+
"purple": "linear-gradient(135deg,#667eea,#764ba2)",
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
PAGE = """<!doctype html>
|
|
38
|
+
<html lang="ar"><head><meta charset="utf-8">
|
|
39
|
+
<title>__TITLE__</title>
|
|
40
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
41
|
+
<style>
|
|
42
|
+
html,body{margin:0;height:100%;background:__BG__;font-family:system-ui,sans-serif}
|
|
43
|
+
body{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:14px}
|
|
44
|
+
#wrap{display:inline-block;line-height:0;overflow:hidden;background:#000;__FRAME__}
|
|
45
|
+
#s{height:80vh;max-width:92vw;object-fit:contain;cursor:pointer;user-select:none;-webkit-user-drag:none;touch-action:none}
|
|
46
|
+
#bar{display:flex;gap:8px;align-items:center}
|
|
47
|
+
button,input{border:0;border-radius:10px;padding:10px 14px;font-size:15px}
|
|
48
|
+
button{background:#ffffffcc;cursor:pointer} button:hover{background:#fff}
|
|
49
|
+
input{width:200px}
|
|
50
|
+
</style></head><body>
|
|
51
|
+
<div id="wrap"><img id="s" draggable="false"></div>
|
|
52
|
+
<div id="bar">
|
|
53
|
+
<button onclick="key(4)">◀ رجوع</button>
|
|
54
|
+
<button onclick="key(3)">⬤ Home</button>
|
|
55
|
+
<button onclick="key(187)">▣ Recent</button>
|
|
56
|
+
<input id="t" placeholder="اكتب نص وادوس Enter">
|
|
57
|
+
</div>
|
|
58
|
+
<script>
|
|
59
|
+
const s=document.getElementById('s'), t=document.getElementById('t');
|
|
60
|
+
let busy=false;
|
|
61
|
+
function refresh(){ if(busy) return; busy=true; s.src='/screen.png?'+Date.now(); }
|
|
62
|
+
s.onload=()=>{busy=false; setTimeout(refresh,60)};
|
|
63
|
+
s.onerror=()=>{busy=false; setTimeout(refresh,500)};
|
|
64
|
+
refresh();
|
|
65
|
+
|
|
66
|
+
function pos(e){
|
|
67
|
+
const r=s.getBoundingClientRect();
|
|
68
|
+
const sc=Math.min(r.width/s.naturalWidth, r.height/s.naturalHeight);
|
|
69
|
+
const w=s.naturalWidth*sc, h=s.naturalHeight*sc;
|
|
70
|
+
const ox=r.left+(r.width-w)/2, oy=r.top+(r.height-h)/2;
|
|
71
|
+
return {x:Math.round((e.clientX-ox)/sc), y:Math.round((e.clientY-oy)/sc)};
|
|
72
|
+
}
|
|
73
|
+
let start=null, t0=0;
|
|
74
|
+
s.addEventListener('pointerdown',e=>{start=pos(e);t0=Date.now();s.setPointerCapture(e.pointerId)});
|
|
75
|
+
s.addEventListener('pointerup',e=>{
|
|
76
|
+
if(!start) return;
|
|
77
|
+
const end=pos(e), d=Math.hypot(end.x-start.x,end.y-start.y);
|
|
78
|
+
if(d<15) fetch(`/tap?x=${end.x}&y=${end.y}`);
|
|
79
|
+
else fetch(`/swipe?x1=${start.x}&y1=${start.y}&x2=${end.x}&y2=${end.y}&ms=${Math.max(100,Date.now()-t0)}`);
|
|
80
|
+
start=null;
|
|
81
|
+
});
|
|
82
|
+
function key(k){fetch('/key?code='+k)}
|
|
83
|
+
t.addEventListener('keydown',e=>{
|
|
84
|
+
if(e.key==='Enter'&&t.value){fetch('/text?v='+encodeURIComponent(t.value));t.value=''}
|
|
85
|
+
});
|
|
86
|
+
</script></body></html>"""
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
class _Device:
|
|
90
|
+
def __init__(self, serial=None):
|
|
91
|
+
if not shutil.which("adb"):
|
|
92
|
+
raise RuntimeError("adb مش موجود. نزّل platform-tools وضيفه للـ PATH.")
|
|
93
|
+
self.serial = serial
|
|
94
|
+
if serial and ":" in serial:
|
|
95
|
+
subprocess.run(["adb", "connect", serial], capture_output=True)
|
|
96
|
+
|
|
97
|
+
def adb(self, *args):
|
|
98
|
+
cmd = ["adb"] + (["-s", self.serial] if self.serial else []) + list(args)
|
|
99
|
+
return subprocess.run(cmd, capture_output=True).stdout
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
def _package_name(apk_path):
|
|
103
|
+
try:
|
|
104
|
+
from pyaxmlparser import APK
|
|
105
|
+
return APK(apk_path).package
|
|
106
|
+
except Exception:
|
|
107
|
+
return None
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
def run(apk, template="phone", background="dark", port=5000,
|
|
111
|
+
device=None, title="APK Web", open_browser=True):
|
|
112
|
+
"""شغّل الـ APK وافتحه في المتصفح.
|
|
113
|
+
|
|
114
|
+
apk : مسار ملف الـ APK
|
|
115
|
+
template : phone | tablet | minimal | retro | none
|
|
116
|
+
background : dark | light | sunset | ocean | purple | أو أي CSS (لون/gradient/url(...))
|
|
117
|
+
device : serial الجهاز، مثلاً "127.0.0.1:5555" (اتركه فاضي لو جهاز واحد)
|
|
118
|
+
"""
|
|
119
|
+
if template not in TEMPLATES:
|
|
120
|
+
raise ValueError(f"القالب مش موجود. المتاح: {list(TEMPLATES)}")
|
|
121
|
+
bg = BACKGROUNDS.get(background, background)
|
|
122
|
+
|
|
123
|
+
dev = _Device(device)
|
|
124
|
+
print("→ تنصيب الـ APK ...")
|
|
125
|
+
print(dev.adb("install", "-r", apk).decode(errors="ignore").strip())
|
|
126
|
+
pkg = _package_name(apk)
|
|
127
|
+
if pkg:
|
|
128
|
+
dev.adb("shell", "monkey", "-p", pkg, "-c",
|
|
129
|
+
"android.intent.category.LAUNCHER", "1")
|
|
130
|
+
print(f"→ تم تشغيل {pkg}")
|
|
131
|
+
else:
|
|
132
|
+
print("مقدرتش أعرف اسم الباكج (pip install pyaxmlparser). افتح التطبيق يدوي.")
|
|
133
|
+
|
|
134
|
+
page = (PAGE.replace("__TITLE__", title)
|
|
135
|
+
.replace("__BG__", bg)
|
|
136
|
+
.replace("__FRAME__", TEMPLATES[template]))
|
|
137
|
+
|
|
138
|
+
app = Flask(__name__)
|
|
139
|
+
|
|
140
|
+
@app.route("/")
|
|
141
|
+
def home():
|
|
142
|
+
return page
|
|
143
|
+
|
|
144
|
+
@app.route("/screen.png")
|
|
145
|
+
def screen():
|
|
146
|
+
return Response(dev.adb("exec-out", "screencap", "-p"), mimetype="image/png")
|
|
147
|
+
|
|
148
|
+
@app.route("/tap")
|
|
149
|
+
def tap():
|
|
150
|
+
dev.adb("shell", "input", "tap", request.args["x"], request.args["y"])
|
|
151
|
+
return "ok"
|
|
152
|
+
|
|
153
|
+
@app.route("/swipe")
|
|
154
|
+
def swipe():
|
|
155
|
+
a = request.args
|
|
156
|
+
dev.adb("shell", "input", "swipe", a["x1"], a["y1"], a["x2"], a["y2"], a["ms"])
|
|
157
|
+
return "ok"
|
|
158
|
+
|
|
159
|
+
@app.route("/key")
|
|
160
|
+
def key():
|
|
161
|
+
dev.adb("shell", "input", "keyevent", request.args["code"])
|
|
162
|
+
return "ok"
|
|
163
|
+
|
|
164
|
+
@app.route("/text")
|
|
165
|
+
def text():
|
|
166
|
+
v = request.args["v"].replace(" ", "%s")
|
|
167
|
+
dev.adb("shell", "input", "text", v)
|
|
168
|
+
return "ok"
|
|
169
|
+
|
|
170
|
+
url = f"http://localhost:{port}"
|
|
171
|
+
print(f"→ افتح {url}")
|
|
172
|
+
if open_browser:
|
|
173
|
+
threading.Timer(1, lambda: webbrowser.open(url)).start()
|
|
174
|
+
app.run(port=port, threaded=True)
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "apkweb"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Run an Android APK in your browser in two lines of Python (via adb)."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.8"
|
|
11
|
+
license = {text = "MIT"}
|
|
12
|
+
authors = [{name = "e5310012"}]
|
|
13
|
+
keywords = ["apk", "android", "emulator", "adb", "browser", "web"]
|
|
14
|
+
dependencies = ["flask", "pyaxmlparser"]
|
|
15
|
+
classifiers = [
|
|
16
|
+
"Programming Language :: Python :: 3",
|
|
17
|
+
"License :: OSI Approved :: MIT License",
|
|
18
|
+
"Operating System :: OS Independent",
|
|
19
|
+
"Topic :: Software Development :: Testing",
|
|
20
|
+
]
|
|
21
|
+
|
|
22
|
+
[tool.setuptools]
|
|
23
|
+
py-modules = ["apkweb"]
|
apkweb-0.1.0/setup.cfg
ADDED