Op 08-07-2021 om 15:42 schreef vergos....@gmail.com:
i just moved from bottleframework to flask. I changes what needed to be altered to 
convert the code and when i run it i just get "Internal server error"
This error is the error any web site shows when the code of your application has an error.
How can i find out what is the culprit here?

     [nikos@superhost wsgi]$ export FLASK_APP=www.py
     [nikos@superhost wsgi]$ export FLASK_ENV=development
     [nikos@superhost wsgi]$ flask run
      * Serving Flask app 'www.py' (lazy loading)
      * Environment: development
      * Debug mode: on
     Usage: flask run [OPTIONS]
     Try 'flask run --help' for help.
Error: While importing 'www', an ImportError was raised: Traceback (most recent call last):
       File "/usr/local/lib/python3.6/site-packages/flask/cli.py", line 256, in 
locate_app
         __import__(module_name)
       File "/home/nikos/wsgi/www.py", line 4, in <module>
         import counters
       File "/home/nikos/wsgi/counters.py", line 6, in <module>
         from flask import run, route, request, redirect
     ImportError: cannot import name 'run'

When I import flask in the REPL (the Python command processor) and look at what it exports:

>>> import flask
>>> dir(flask)
['Blueprint', 'Config', 'Flask', 'Markup', 'Request', 'Response', 'Session', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__', '__version__', '_app_ctx_stack', '_compat', '_request_ctx_stack', 'abort', 'after_this_request', 'app', 'appcontext_popped', 'appcontext_pushed', 'appcontext_tearing_down', 'before_render_template', 'blueprints', 'cli', 'config', 'copy_current_request_context', 'ctx', 'current_app', 'escape', 'flash', 'g', 'get_flashed_messages', 'get_template_attribute', 'globals', 'got_request_exception', 'has_app_context', 'has_request_context', 'helpers', 'json', 'json_available', 'jsonify', 'make_response', 'message_flashed', 'redirect', 'render_template', 'render_template_string', 'request', 'request_finished', 'request_started', 'request_tearing_down', 'safe_join', 'send_file', 'send_from_directory', 'session', 'sessions', 'signals', 'signals_available', 'stream_with_context', 'template_rendered', 'templating', 'url_for', 'wrappers']
... there is no "run" there. What were you trying to achieve?

If you are thinking about the "flask run" mentioned in startup, that is a bash/cmd command, an easy way to start the server from the command line:

(venv):~/python/debtors> export FLASK_APP=debtors ; flask run
 * Serving Flask app "debtors"
 * Environment: production
WARNING: This is a development server. Do not use it in a production deployment.
   Use a production WSGI server instead.
 * Debug mode: off
 * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)


--
Met vriendelijke groet / Kind regards

Menno Hölscher


--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to