1

Currently I am starting my flask server by executing the FLASK_APP=name_of_my_app.py && flask run (I am on Ubuntu). I need to achieve the outcome of initiating the server as above through different means - namely, by running something of the kind: python start_same_server.py. After some refactoring, this does not work for me because it breaks my socket.io (flask-socketio). So I had an idea of just creating a supplementary start_server.py module that looks like this:

enter image description here

Please ignore the Windows shell command (it may be wrong, I have not tested it yet). But I am getting an error in my shell when I do python start_server.py:

/bin/sh: 1: flask: not found

It is because of my lack of understanding on how Popen runs shell commands. How do I make Popen see my flask command? (I had an idea of adding flask to sys.path? Also can python -m flask help here somehow?)

Sorry for the noob question. And thanks for any help.

2
  • Can you run this exact command from the terminal, without Python? Commented Mar 5, 2018 at 13:23
  • yeap, I can.... Commented Mar 5, 2018 at 13:23

2 Answers 2

1

You should use the path to the flask command in the virtualenv, like /home/user/venv/bin/site-packages/flask. flask is not installed to the system, it's just module in the Python virtualenv.

Sign up to request clarification or add additional context in comments.

2 Comments

hmm. let me try that. That would be equivalent of adding that path to the sys.path I think
there is no flask module there. There is a _main_.py file which is alias for flask run. But when I do python /../../__main__.py it tells me that: ModuleNotFoundError: No module named 'main.cli'; 'main' is not a package. i.e. it does not see the whole package
0

Try

Python -m pip install flask
#or ...-m easy_install flask

Why not you try this for the batter result

from flask import Flask as f,  Merkup as m
app = f(__name__)
@app.route('/')
def main():
 html = open('index.html').read()
 html = m(html)
 return html

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.