pyscript icon indicating copy to clipboard operation
pyscript copied to clipboard

Trouble converting flask python script

Open Tsjippy opened this issue 1 year ago • 0 comments

I have a 'server.py' script that runs a server and a webpage using flask. I am trying to move that to pyscript but don't know completely how to do that.

See the source code here

I just copied all the files to the pyscript folder, moved the dependent file 'sql_functions.py' to the modules folder, and added a requirements.txt with flask as content.

But trying to run the script gives me these errors:

Exception in </config/pyscript/server.py> line 30: @app.route('/', methods=['GET']) ^ AttributeError: 'EvalFunc' object has no attribute '__name__'
Exception in </config/pyscript/server.py> line 2: import sql_functions ^ ModuleNotFoundError: No module named 'sql_functions'
Exception in </config/pyscript/server.py> line 35: @app.route('/', methods=['GET']) ^ AttributeError: 'EvalFunc' object has no attribute '__name__'
Exception in </config/pyscript/modules/sql_functions.py> line 11: base_path = os.path.dirname(os.path.realpath(__file__))+'/' ^ NameError: name '__file__' is not defined

Any help appreciated

Tsjippy avatar Nov 04 '24 14:11 Tsjippy