question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

flaskwebgui is getting killed immediately

See original GitHub issue

Hi, I have just created an single page flask web app all it does is say hello world here is the program

# gui.py
from flask import Flask
from flaskwebgui import FlaskUI
from os import path

b_path = path.join(path.dirname(__file__), 'Browsor', 'chrlauncher.exe')

app = Flask(__name__)
ui = FlaskUI(app, fullscreen=True, start_server='flask',browser_path= b_path)

@app.get('/')
def home():
    return "Hello World"

@app.get('/page')
def page():
    return '''
            This is Another Page
            <a href="/">Go To Home page</a>
            '''


if __name__ == '__main__':
    ui.run()

when i run this file python3 gui.py
it start chromium and program ends after that, which is why it shows Screenshot (71)

and this is on terminal Capture

and i am using this chromium version

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:28 (13 by maintainers)

github_iconTop GitHub Comments

9reactions
ClimenteAcommented, Jun 14, 2021

Version 0.3.0 should fix this issue.

3reactions
davo456commented, Aug 3, 2022

As we can find at flaskwebgui documentation is required to create an additional configuration in order to keep alive de process during the UI execution time.

Inside your static folder you should create a .js file with the following config:

App Path/static/js/keep.alive.js

async function getRequest(url='') {
    const response = await fetch(url, {
      method: 'GET', 
      cache: 'no-cache'
    })
    return response.json()
}

document.addEventListener('DOMContentLoaded', function() {

let url = document.location
let route = "/flaskwebgui-keep-server-alive"
let interval_request = 3 * 1000 //sec

function keep_alive_server(){
    getRequest(url + route)
    .then(data => console.log(data))
}

setInterval(keep_alive_server, interval_request)()

})

Inside every HTML file used by the UI you should add the following lines:

<script src="{{ url_for('static', filename='js/keep.alive.js')}}"></script>

An that’s it!! Hope this work for you!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Flask shutdown after working 10-15 sec - Stack Overflow
I am developing a python messenger Bot using a wrapper from pymessenger. It works locally but in production it breaks.Like in every sec...
Read more >
flaskwebgui 0.1.8 - PyPI
from flask import Flask from flaskwebgui import FlaskUI #get the ... in development mode and all running Chrome processes will be killed.
Read more >
Advantage to Tkinter vs Others : r/learnpython - Reddit
I've only done a couple tkinter projects but I can say PSG is way quicker to get something up and running quickly.
Read more >
App closes immediately after start in new version (0.1.7),about ...
If any Chrome window is already opened - app closes immediately after start. ... Start_server parameter HOT 2; flaskwebgui is getting killed immediately...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found