Installing Flask on Ubuntu - python

I'm having difficulty installing Flask on my Ubuntu machine. In fact, I tried 2 different Ubuntu computers and neither of them worked.
I followed this tutorial https://pythonprogramming.net/creating-first-flask-web-app/ where all steps are well explained.
The problem is. When I type localhost:5000 or just localhost or 127.0.0.1:5000 I get "Can't connect. Something is broken" you know that sort of message you get when server can't find index.html or index.php
Everything during the installation went okay. The only thing that didn't work well was installing virtual environment. It downloaded okay but when I ran sudo virtualenv xyz I got No such command. But Django & Flask can work without it so it shouldn't be an issue.
Any ideas ?
I deleted those as Flask don't need files to be named index.html.

Related

I am getting this error The DNS operation timed out after 20.000144004821777 seconds when running my app in cygwin instead of my windows terminal

so I am trying to do some background job to run in my flask app , and in order to run the worker, I needed to use cygwin instead of my windows terminal. My application use MongoDb Atlas for documents storage and it works perfectly fine when I "flask run" it from my cmd . But I got the error once I run it or run the worker from cygwin. It is to note that I whitelisted my IP adress and installed the dnspython package , and still got the error.
Any suggestions about what could be the problem? I don't seem to find any answer in previous asked questions . Thank you.
It's because of your dynamic DNS configuration from your ISP. make it static or you can use googleDNS server which is 8.8.8.8 or 8.8.4.4 as your DNS servers.
I hit and resolved this same issue hit today w/ cygwin, python3.8, dnspython 1.16.0 by updating to dnspython 2.0.0 and ensuring there was a valid /etc/resolv.conf in place.

Django: ERR_CONNECTION_REFUSED

I'm actually learning to use the Django framework with PostgreSQL with Docker and docker-compose.
Regularly, when I make a mistake (for example a syntax error in the views.py file), I cannot reach my Django app anymore trough my web browser.
Firefox tells me:
Unable to connect
Firefox can't establish a connection to the server at localhost:8000
Chrome tells me:
This site can’t be reached
localhost refused to connect.
ERR_CONNECTION_REFUSED
I had this several times and I always managed to find the error in my code, to correct it and then everything went well again.
Currently, my code is working fine. But if I encounter this again (and this happens very often), I would like to be able to find the error quickly by myself.
So here is my question:
How can I see which file at which line contains the error ?
I would like to have a correct error message telling me what went wrong instead of that annoying ERR_CONNECTION_REFUSED browser page over and over.
I hope I explained my issue well because I struggled to describe it to Google.
Thanks a lot in advance. :)
FYI:
Ubuntu 18.04.3 LTS Bionic (window manager i3wm)
Docker 19.03.4
docker-compose 1.17.1
python 3.7 (docker image)
Django 2.2.6 (inside the python 3.7 image)
PostgreSQL 12.0 (docker image)
Visual Studio Code 1.39.2
I finally found a solution.
I had the bad habit to run my docker-compose in detached mode.
When attached, the syntax errors are shown directly from the terminal when de container is stopped.
I also added a script where I run my server in a loop. This way, the server will relaunch automatically over and over until I correct the error. I don't have to restart my Django server manually.
Thank you for helping me anyway.

how to diagnose Apache2.4 service error 7024 Incorrect function

System:
Windows 10 x64 (enterprise computer with some restrictions)
Apache 2.4 64-bit
Python 3.7.1 64-bit
mod_wsgi (built today from github using python setup.py install)
I am working on getting an Apache server with Python on a Windows machine and I have the server configured correctly in order to get the Hello World! example from mod_wsig documentation working.
If I simply launch C:\Apache24\bin\httpd.exe, this works and I see Hello World at http://localhost:5000/
Then I wanted to get it running as a service, so I call
httpd.exe -k install
In the ApacheMonitor I start the new Apache2.4 service but I get a failed to start error. In the Windows system event log it says Event ID: 7024 with a service specific error: Incorrect function.
When I run httpd.exe -k start -n "Apache2.4" -t it says Syntax OK
What I can't find is any more information about the service error. Nothing populates in the error.log file and I don't know where else to look, and I am asking for any further information on how to diagnose this.
Before I started configuring Apache to use mod_wsgi, launching the service was successful, so this happened after doing that, and I haven't configured anything else at this point.
Go to the Command Prompt move to the apache/bin folder and type
>httpd -t
This will give you more information about the error preventing Apache from start.
I was getting this error after updating my httpd.conf file. The problem was that my final xml tag in httpd.conf was unclosed </directory without the closing >.
This days I was facing the same situation, windows 10, apache24, django app, python3.8, failing to start as service, service events showing error 7024...
So, after a lot of struggling and research, I would like to add my solution even this is an old question.
The solution was to add two environment variables, no in httpd.conf, not in python code/conf but at SO level (windows > environment variables)
PYTHONHOME = c:\your\path\to\installed\python
PYTHONPATH = c:\your\path\to\installed\virtualenv
And magic! apache now works as service and the django app is always available on localhost

Cannot connect to Heroku through cmd line

I have a Django project that I have deployed on a heroku web server and use PyCharm as my IDE. I used to be able to interact with my web server with "heroku run bash", however, now when I try running "heroku run bash" I get:
▸ stat /.local/share/heroku/client/bin/heroku: not a directory
▸ fork/exec /.local/share/heroku/client/bin/heroku: not a directory
I'm not sure what has changed, but I can't seem to connect to my heroku webserver anymore. I can still push changes using git push heroku master, but any other interaction with my heroku server doesn't seem to work anymore. I've already checked with Heroku and their systems are running just fine.
How do I reconnect to my heroku web server again with PyCharm? Or just in general?
Thanks in advance for your help!
This is either due to a new version of the CLI or to an OS upgrade.
I experienced the exact same issue on my Mac after upgrading to High Sierra and resolved it by reinstalling the CLI, this time using Homebrew.
Had the same problem. Did the following steps, as described here:
1) brew install heroku/brew/heroku
2) which heroku pointed to /usr/local/bin/heroku so no problems there
3) finally brew link --overwrite heroku
After this, everything was sorted and worked as expected.

VirtualBox command works correct in bash, but does not work in nginx

We have a project on nginx/Django, using VirtualBox.
When we try to run command VBoxManage list runningvms in nginx, we have the next error:
Failed to initialize COM because the global settings directory '/.config/VirtualBox' is not accessible!
If we run this command in console, it works fine.
What can we do to make it working good in nginx?
Other details:
nginx is runned by user "www-data", console - by the other user (Administrator).
We have fixed the issue.
There was wrong environment variable "Home" (os.environ['HOME']). We changed it, and so the problem was gone.
Using Python API for VB instead of ssh can really help you with that problem, as RegularlyScheduledProgramming suggested - we added Python API too.
Thanks!

Categories

Resources