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'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)
Share
Improve this question
edited yesterday
Ajeet Verma
3,0563 gold badges16 silver badges27 bronze badges
asked yesterday
user28409312user28409312
153 bronze badges
1
- Please provide the error from the Log Stream. – Aslesha Kantamsetti Commented yesterday
1 Answer
Reset to default 1I 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:
- Add the below line of code to the
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)
- Run the below command to generate the
dist
folder for deployment.
flet publish src/main.py
- While Creating Azure Web App, I selected
Runtime stack
:Node 18
andOperating System
:Windows
.
- Deploy the
dist
Folder to Azure as shown below.
Azure Output: