shanealynn / async_flask

Test of asynchronous flask communication with web page.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

application.js file gets a net::ERR_ABORTED 404 (Not Found)

Logixor opened this issue · comments

Hello everyone, I'm struggling with this for the past two days :'''(, and I have used it before and it was working.

So, I have just created a WS instance with Ubuntu 18.
I clone the repo in my /var/www/html/ and run the python application
The server seems to be running

`Server initialized for eventlet.

  • Restarting with stat
    Server initialized for eventlet.
  • Debugger is active!
  • Debugger PIN: XXX-XXX-XXX
    (7604) wsgi starting up on http:// 127.0.0.1:5000`

When I load the page in my browser (tested with Chrome and Firefox, same result), I see the following error in the console:

GET http://ec2-XX-XX-XXX-XXX.eu-north-1.compute.amazonaws.com/async_flask/templates/static/js/application.js net::ERR_ABORTED 404 (Not Found)

... complaining about line 6 in the index.html file...

<script src="static/js/application.js"></script>

... so I change this to ...

<script src="../static/js/application.js"></script>

... and now I get this error in the browser console on each polling ...

GET http://ec2-XX-XX-XXX-XXX.eu-north-1.compute.amazonaws.com/socket.io/?EIO=3&transport=polling&t=1586010311097-0 404 (Not Found)

... coming from: socket.io.min.js

I have setup my Security Group in the AWS Dashboard. So there are Inbound rules for HTTP and SSH - 80 and 22 respectively.

pip freeze:
asn1crypto==0.24.0 click==7.1.1 cryptography==2.1.4 dnspython==1.16.0 enum34==1.1.6 eventlet==0.25.1 Flask==1.0.2 Flask-SocketIO==3.1.2 greenlet==0.4.15 gyp==0.1 idna==2.6 ipaddress==1.0.17 itsdangerous==1.1.0 Jinja2==2.11.1 keyring==10.6.0 keyrings.alt==3.0 MarkupSafe==1.1.1 monotonic==1.5 pycrypto==2.6.1 pycurl==7.43.0.1 pygobject==3.26.1 pyliblzma==0.5.3 pysqlite==1.0.1 python-engineio==3.12.1 python-socketio==4.5.1 pyxdg==0.25 rpm==4.14.1 SecretStorage==2.3.1 six==1.11.0 urlgrabber==3.10.2 Werkzeug==1.0.1 yum-metadata-parser==1.1.4

pip3 freeze
asn1crypto==0.24.0 attrs==17.4.0 Automat==0.6.0 blinker==1.4 certifi==2018.1.18 chardet==3.0.4 click==6.7 cloud-init==19.4 colorama==0.3.7 command-not-found==0.3 configobj==5.0.6 constantly==15.1.0 cryptography==2.1.4 distro-info===0.18ubuntu0.18.04.1 dnspython==1.16.0 ec2-hibinit-agent==1.0.0 eventlet==0.25.1 Flask==1.1.2 Flask-SocketIO==4.2.1 gevent==1.4.0 gevent-websocket==0.10.1 greenlet==0.4.15 hibagent==1.0.1 httplib2==0.9.2 hyperlink==17.3.1 idna==2.6 incremental==16.10.1 itsdangerous==1.1.0 Jinja2==2.11.1 jsonpatch==1.16 jsonpointer==1.10 jsonschema==2.6.0 keyring==10.6.0 keyrings.alt==3.0 language-selector==0.1 MarkupSafe==1.0 monotonic==1.5 netifaces==0.10.4 oauthlib==2.0.6 PAM==0.4.2 pyasn1==0.4.2 pyasn1-modules==0.2.1 pycrypto==2.6.1 pygobject==3.26.1 PyJWT==1.5.3 pyOpenSSL==17.5.0 pyserial==3.4 python-apt==1.6.5+ubuntu0.2 python-debian==0.1.32 python-engineio==3.12.1 python-socketio==4.5.1 pyxdg==0.25 PyYAML==3.12 requests==2.18.4 requests-unixsocket==0.1.5 SecretStorage==2.3.1 service-identity==16.0.0 six==1.11.0 ssh-import-id==5.7 systemd-python==234 Twisted==17.9.0 ufw==0.36 unattended-upgrades==0.1 urllib3==1.22 virtualenv==15.1.0 Werkzeug==1.0.1 zope.interface==4.3.2

Apache2:
● apache2.service - The Apache HTTP Server
Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
Drop-In: /lib/systemd/system/apache2.service.d
└─apache2-systemd.conf
Active: active (running) since Sat 2020-04-04 12:05:02 UTC; 3h 37min ago
Process: 5039 ExecStop=/usr/sbin/apachectl stop (code=exited, status=0/SUCCESS)
Process: 5044 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS)
Main PID: 5061 (apache2)
Tasks: 55 (limit: 522)
CGroup: /system.slice/apache2.service
├─5061 /usr/sbin/apache2 -k start
├─5062 /usr/sbin/apache2 -k start
└─5063 /usr/sbin/apache2 -k start

Apr 04 12:05:02 ip-XXX-XXX-XXX-XXX systemd[1]: Starting The Apache HTTP Server...
Apr 04 12:05:02 ip-XXX-XXX-XXX-XXX systemd[1]: Started The Apache HTTP Server.

Please, I hope someone can help or shed some light here.

Hi Logixor, there may be some mix up here between your use of Apache and Flask. You can think of these as two different web servers.

Apache is running on port 80, and serving the static files in your /var/www folder - but this is not how you access the flask application.

Flask is running on port 5000, and you'll need to access this on this port (or you can look up setting up a "proxy" to user apache on port 80). But for now, I would open up port 5000 on your Ec2 security group, and try to navigate to http://ec2-XX-XX-XXX-XXX.eu-north-1.compute.amazonaws.com:5000 in your browser. Monitor the output from the flask app when you do this to see if you get a connection attempt.

Thanks for the update :)

I have opened the port, but the result is still the same.

Does it matter where the project is?, I mean:
in /var/www/
in /var/www/html/
or in /var/www/html/async_flask/

If this is still an issue you, may need to put specific rules in your apache setup to route /socket requests.