I'm trying to deploy sample flet app to Azure from vs code getting Azure default page. Is it possible deploy flet app to Azure if it is how? main.py:
import flet as ft
def main(page: ft.Page):
page.title = "Counter App"
text = ft.Text("0", size=30)
def increment(e):
text.value = str(int(text.value) + 1)
page.update()
page.add(
text,
ft.ElevatedButton("Increment", on_click=increment)
)
ft.app(target=main)
I have created a Sample flet app and deployed to Azure App service using vs code.
To deploy flet app to Azure follow the below steps:
main.py
file.ft.app(target=main, view=ft.AppView.WEB_BROWSER)
Below is complete code of my main. py file:
import flet as ft
def main(page: ft.Page):
counter = ft.Text("0", size=50, data=0)
def increment_click(e):
counter.data += 1
counter.value = str(counter.data)
counter.update()
page.floating_action_button = ft.FloatingActionButton(
icon=ft.Icons.ADD, on_click=increment_click
)
page.add(
ft.SafeArea(
ft.Container(
counter,
alignment=ft.alignment.center,
),
expand=True,
)
)
ft.app(target=main, view=ft.AppView.WEB_BROWSER)
dist
folder for deployment.flet publish src/main.py
Runtime stack
: Node 18
and Operating System
: Windows
.dist
Folder to Azure as shown below.Azure Output: