Forums

Flask app syntax error and not working, what am i doing wrong?

I am a very very beginner coder, and I am trying to make a website for my boyfriend, however, I can't figure out what I am doing wrong here

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/bin/pythonanywhere_runner.py", line 26, in _pa_run
code = compile(f.read(), filename.encode("utf8"), "exec")
File "/home/lvrasan/mysite/app.py", line 7
pip install flask
          ^
SyntaxError: invalid syntax

So this shows up for my app.py, the code above.

and:

import sys

# add your project directory to the sys.path
project_home = '/home/lvrasan/mysite'
if project_home not in sys.path:
sys.path = [project_home] + sys.path

# import flask app but need to call it "application" for WSGI to work
from app import app as application  # noqa

It keeps telling me " 'app.app as application' imported by unused"

I don't know what I am doing wrong, it is probably something basic, I am still very new to this. I am happy to provide additional details if needed.

It looks like you have a line pip install flask in "/home/lvrasan/mysite/app.py", which is incorrect, since the pip command should be run in a Bash console, not in a Python script. You don't need to install Flask, unless you want to use a virtual environment, as it's already pre-installed on PythonAnywhere.