I'm learning django(4.1) channels(4.0.0) from a YouTube video and now trying to configure ASGi. Using windows and gitbash. After configuration when I run server, instead of showing: Starting ASGI/Channels version 4.0.0 development server at http://127.0.0.1:8000
it simply shows: Starting development server at http://127.0.0.1:8000/
which instructor says it means "Channels development server does not taking over my Django development server as it should."
We literally just made a project(mywebsite) and an app(chat), added channels and the app to setting, and in settings we added
ASGI_APPLICATION = 'mywebsite.asgi.application'
asgi.py
import os
from django.core.asgi import get_asgi_application
from channels.routing import ProtocolTypeRouter
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mywebsite.settings')
application = ProtocolTypeRouter({
'http': get_asgi_application(),
})
I have compared my code to his from the source code he provided and nothing in different. Do I have a problem from my computer settings?
Related
I have a Flask application that I'm trying to configure for a production environment. So far, during testing python app.py inside of a virtualenv works fine.
However, I'm beginning to configure the application to begin using UWSGI. When I attempt to start the Flask app using
$ uwsgi -s /tmp/myapplication.sock --manage-script-name --mount /myapplication=app:app
--virtualenv /path/to/my/venv
I get a
ModuleNotFoundError: No module named 'flask_httpauth'
I was wondering if anyone has experience w/ that authentication module and if they have any advice on what I should do. I'm unsure of why the development server starts without an issue, but the uwsgi server (that I pass the same virtualenv that's used for the dev server) runs into import issues
I was able to resolve this issue by setting the home path to my virtualenv directory (.venv in my case):
# uwsgi.ini
home = /Users/floatingrock/Desktop/projects/google_v2/.venv/
If you're wondering, I got the full path using pwd.
Background: I am new to Flask (and fairly new to python, linux terminal, servers). I have gone through the tutorial http://flask.pocoo.org/docs/1.0/tutorial/.
I am developing on raspberry pi 3, via putty from my PC.
I run flask, according to the tutorial:
export FLASK_APP=flaskr
export FLASK_ENV=development
flask run
According to the tutorial I can make changes to the code and the server will automatically reload.
My issue: I don't know how to make changes to my code without stopping Flask (ctrl+c).
How can I leave Flask, return to the Linux Terminal, edit my code, and then return to the Flask Debugger without stopping Flask each time?
I have reviewed the Flask Docs http://flask.pocoo.org/docs/1.0/ to no avail.
Thanks,
You has to enable the debug mode. Default debug is True in flask
app.run(debug=True) or export DEBUG=True
you can go through this link for Flask configuration
http://flask.pocoo.org/docs/1.0/config/#configuring-from-environment-variables
If you are using Flask >=1.0v you need to set environment in development mode.
export FLASK_ENV='development'
I am developing a Django app but unfortunately my laptop is broken and will take a month to get repaired. So mean while I am using a android app called Termux to work on the project. But Termux still doesn't have a postgresql package and don't want to mess my settings just for running the project. So how can I use dj_database_url packages to configure my databases using database urls??
This can be done using the dj_database_url module.
After installing the module in the project, then this config needs to be done(example for default database):
db_from_env=dj_database_url.config(conn_max_age=500)
DATABASES['default'].update(db_from_env)
Now export a environment variable named DATABASE_URL for the database server
More info here: https://github.com/kennethreitz/dj-database-url/blob/master/README.rst
My Django project is not being served while running on Apache 2.2.
All I can see is the folder structure upon hitting the URL of the domain name.
I've mod_wsgi installed but I think it's not linked well.
Can anybody tell what may be the problem?
Here's the URL of the website
http://ccbstca.ccbst.info/
UPDATE 1
You need to install and enable mod_wsgi for apache. And specify WSGIScriptAlias in apache virtual host config. This link might help:
http://thecodeship.com/deployment/deploy-django-apache-virtualenv-and-mod_wsgi/
ORIGINAL
I think You need to name your wsgi script file as a python file (.py)
And following wsgi code might just help:
import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "ppbase.settings")
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
If you can post your apache virtual host config file, it would help in answering this.
I wanted to start getting into developing with Django, however, I am unable to figure out how to make it work. I have installed apache2, I have tried many tutorials on configuring apache to run Django, but I just do not understand how it all works together. Can someone give me a dummies guide on how to install it, how things work, and why?
The best way to link between Django and Apache is using WSGI. You will need to install the mod_wsgi apache module to do this.
Next step: modify the apache configuration file to designate where you want the root of your django website.
WSGIScriptAlias / /path/to/mysite/apache/myApp.wsgi
Next, you should create the wsgi file. This is what initializes your django application. An example wsgi file looks like this
import sys
import os
sys.path.insert(0,os.path.normpath(os.path.dirname(os.path.abspath(__file__))))
sys.path.insert(0,'/path/to/directory/containing/application')
import django.core.handlers.wsgi
os.environ['DJANGO_SETTINGS_MODULE'] = 'twitmycity.settings'
application = django.core.handlers.wsgi.WSGIHandler()
Once you have this, restart apache
sudo /etc/init.d/apache2 restart
Now, point your browser to the root directory where you established the wsgi handler. This should bring you to the root to your django application. I hope this helps!
Also note, when you make a change to your application, you need to refresh the modified time on the wsgi file to prevent wsgi from just using a cache version of the django application. To do this, execute
touch myApp.wsgi