DEFAULT_FLET_PATH = ''
DEFAULT_FLET_PORT = 8502
def main(page: ft.Page):
page.title = "Flet is Working"
page.vertical_alignment = ft.MainAxisAlignment.CENTER
txt_number = ft.TextField(value="0", text_align=ft.TextAlign.RIGHT, width=100)
def minus_click(e):
txt_number.value = str(int(txt_number.value) - 1)
page.update()
def plus_click(e):
txt_number.value = str(int(txt_number.value) + 1)
page.update()
page.add(
ft.Row(
[
ft.IconButton(ft.icons.REMOVE, on_click=minus_click),
txt_number,
ft.IconButton(ft.icons.ADD, on_click=plus_click),
],
alignment=ft.MainAxisAlignment.END,
)
)
if __name__ == "__main__":
#flet_path = os.getenv("FLET_PATH", DEFAULT_FLET_PATH)
flet_path ='app'
flet_port = int(os.getenv("FLET_PORT", DEFAULT_FLET_PORT))
ft.app(name=flet_path, target=main, view=None, port=flet_port)
DEFAULT_FLET_PATH = 'http:/ip/'
don't try to specify the ip address, because your app must be running on local interface (you can test it open the port 8502 in your firewall and try connect to http://ip:port). Nginx serve your webapp as a reverse proxy like django app.-
Nginx for flet app config file:
server {
listen 80;
listen 443;
server_name ip or domain;
location = /favicon.ico { access_log off; log_not_found off; }
location / {
proxy_pass http://127.0.0.1:8502/;
proxy_redirect off;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection keep-alive;
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
location /ws {
proxy_pass http://127.0.0.1:8502/ws;
proxy_redirect off;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
if is all is rigth you can access by:
http://ip/app
I hope help you!