最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

python - Is it possible to deploy flet app to Azure app service? - Stack Overflow

programmeradmin3浏览0评论

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
Add a comment  | 

1 Answer 1

Reset to default 1

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:

  • 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 and Operating System : Windows.

  • Deploy the dist Folder to Azure as shown below.

Azure Output:

发布评论

评论列表(0)

  1. 暂无评论