Closed hanchenglong001 closed 1 week ago
Code example to reproduce the issue:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>调用相机拍照</title> </head> <body> <input type="file" accept="image/*" capture="camera" id="cameraInput"> <img id="previewImage" src="" alt="预览图"> <script> const cameraInput = document.getElementById('cameraInput'); const previewImage = document.getElementById('previewImage'); cameraInput.addEventListener('change', (event) => { const file = event.target.files[0]; const reader = new FileReader(); reader.onload = (e) => { previewImage.src = e.target.result; }; reader.readAsDataURL(file); }); </script> </body> </html>
import time import flet as ft import threading from flask import Flask,send_file,render_template PORT=5000 app = Flask(__name__) @app.route('/') def hello_world(): return render_template(r"html/test.html") def run_flask_in_thread(): app.run(host='0.0.0.0', port=PORT) def main(page: ft.Page): page.title = "测试工具" flask_thread = threading.Thread(target=run_flask_in_thread) flask_thread.start() page.navigation_bar = ft.NavigationBar( destinations=[ ft.NavigationDestination(icon=ft.icons.EXPLORE, label="首页") ] ) wv = ft.WebView( url=f"http://localhost:{PORT}/", expand=True, on_page_started=lambda _: print("Page start"), on_page_ended=lambda _: print("Page ended"), on_web_resource_error=lambda e: print("Page error:", e.data), ) page.add(wv) ft.app(target=main)
I added the AndroidManifest. XML
<uses-permission android:name="android.permission.CAMERA" />
Describe the results you received: Clicking the button does not turn on the camera properly. But it is call the camera by opening a web page in a mobile browser.
Windows python3.9 Android12
flet==0.22.* requests==2.31.0 flask==3.0.3
Description
I tried using webview in an Android app packaged with flet. Then call the camera module in the html page. But it failed.
Code example to reproduce the issue:
test.html
main.py
I added the AndroidManifest. XML
Describe the results you received: Clicking the button does not turn on the camera properly. But it is call the camera by opening a web page in a mobile browser.
Operating system:
Windows python3.9 Android12
requirements.txt
flet==0.22.* requests==2.31.0 flask==3.0.3