Why is my flask class not working properly?

I want to use flask for a project I have, but it is arising many issues.
here is the code:

import flask as f
from flaskwebgui import FlaskUI

class Game(f.Flask(__name__)):
  def __init__(self):
    super().__init__()
    app = FlaskUI(self, width=100, height=100)
     
    @self.route('/')
    def homepage():
      return f.render_template("game.html")

    app.run()

Why doesn’t it work?

import flask as f
from flaskwebgui import FlaskUI

class Game(f.Flask)
  def __init__(self):
    super().__init__(__name__)
     
    @self.route('/')
    def homepage():
      return f.render_template("game.html")

    FlaskUI(self, server="flask").run("0.0.0.0")

should work I changed the inheritance to be properly working and also added the FlaskUI to conform the the docs

1 Like

Returned error:

Exception in thread Thread-1:
Traceback (most recent call last):
  File "/nix/store/hd4cc9rh83j291r5539hkf6qd8lgiikb-python3-3.10.8/lib/python3.10/threading.py", line 1016, in _bootstrap_inner
    self.run()
  File "/nix/store/hd4cc9rh83j291r5539hkf6qd8lgiikb-python3-3.10.8/lib/python3.10/threading.py", line 953, in run
    self._target(*self._args, **self._kwargs)
TypeError: Flask.__call__() missing 2 required positional arguments: 'environ' and 'start_response'

Hmm, is this from FlaskUI or from Flask?

I altered the code a little since the one provided returned errors.

1 Like

Here is the altered version of your code:

import flask as f
from flaskwebgui import FlaskUI

class Game(f.Flask):
  def __init__(self):
    super().__init__(__name__)
     
    @self.route('/')
    def homepage():
      return f.render_template("game.html")

    FlaskUI(self).run()
1 Like

Unsure but I believe flaskui. It was returning a “browser path not found” error. When I tried adding a small portable version of pale moon and added that path, it said “access denied”.

1 Like

thanks but I sorta fixed it, right so if you could mark mine as solved, that would be great

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.