Django App Not Working

I am working on a simple Django app to say “Hello, world!” but Glitch is not letting me access the project directory. This means that I cannot use Django’s default files. However, I can make directories with the same name as my project. Is there a way to change this behaviour?

Can you explain a bit more and link the project. I’m having a bit of trouble following you.

1 Like

The directory is now accessible. But there is still a problem. I cannot the load the project page (it is showing me a 504 error) and I am continuously getting an error in the logs saying there is no such file or directory called “app” but there is, and in fact, it is what my project is called. This is my project URL-


.

Could you show me your logs and more all of the files back to the main directory? I want to see what error comes up when I do that.

1 Like

Here is the error message-
/opt/watcher/app-types/node/start.sh: line 51: cd: app,: No such file or directory. I also got an error 502 just now.

Add all the files back to the main directory and remove the cd app

I now get this error-
File "manage.py", line 17 ) from exc ^ SyntaxError: invalid syntax. The manage.py file is generated by Django. It should not have any bug.

Also, my project is public.

Update:
I now get this error after visiting the project page-

failed to start application on melodic-lava-antelope.glitch.me This is most likely because your project has a code error. Check your project logs, fix the error and try again.

I wonder if this is a Glitch bug.

it could be an issue with your python version or you may have delete some of it, can we have a snippet of the code in the line 17 area?
It’s not a glitch bug, it’s defintley with your code, also you are already in your /app directory when your project starts

This is my current package.json-

{
  "name": "hello-express",
  "version": "0.0.1",
  "description": "A simple Node app built on Express, instantly up and running.",
  "main": "server.js",
  "scripts": {
    "start": "python manage.py runserver"
  },
  "dependencies": {
    "express": "^4.17.1"
  },
  "engines": {
    "node": "12.x"
  },
  "repository": {
    "url": "https://glitch.com/edit/#!/hello-express"
  },
  "license": "GPL-3.0",
  "keywords": [
    "node",
    "glitch",
    "express"
  ]
}

and I think only line 17 is not enough, it is a part of a definition of the main() function-

def main():
    """Run administrative tasks."""
    os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'app.settings')
    try:
        from django.core.management import execute_from_command_line
    except ImportError as exc:
        raise ImportError(
            "Couldn't import Django. Are you sure it's installed and "
            "available on your PYTHONPATH environment variable? Did you "
            "forget to activate a virtual environment?"
        ) from exc
    execute_from_command_line(sys.argv)

. I do not think I have changed anything here.
And the project is shared; you can view it here.

Update:
I forgot that Glitch uses Python 2 by default; I have changed the package.json file to use Python 3.
This is how my log looks like now-

Watching for file changes with StatReloader
(node:1792) UnhandledPromiseRejectionWarning: Error: connect ECONNREFUSED 127.0.0.1:1988
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1054:14)
(node:1792) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:1792) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

When I visit the project page, I get this error now-

Site didn’t respond

Something in the code caused it to close the connection before providing a response.

If this is your project please visit us at support.glitch.com for assistance.

Update:
I added the project URL to ALLOWED_HOSTS in settings.py, removed engines from package.json, and it is working as intended now!