initial commit
This commit is contained in:
0
backend/mesa/__init__.py
Normal file
0
backend/mesa/__init__.py
Normal file
BIN
backend/mesa/__pycache__/__init__.cpython-310.pyc
Normal file
BIN
backend/mesa/__pycache__/__init__.cpython-310.pyc
Normal file
Binary file not shown.
BIN
backend/mesa/__pycache__/__init__.cpython-312.pyc
Normal file
BIN
backend/mesa/__pycache__/__init__.cpython-312.pyc
Normal file
Binary file not shown.
BIN
backend/mesa/__pycache__/asgi.cpython-312.pyc
Normal file
BIN
backend/mesa/__pycache__/asgi.cpython-312.pyc
Normal file
Binary file not shown.
BIN
backend/mesa/__pycache__/settings.cpython-310.pyc
Normal file
BIN
backend/mesa/__pycache__/settings.cpython-310.pyc
Normal file
Binary file not shown.
BIN
backend/mesa/__pycache__/settings.cpython-312.pyc
Normal file
BIN
backend/mesa/__pycache__/settings.cpython-312.pyc
Normal file
Binary file not shown.
BIN
backend/mesa/__pycache__/urls.cpython-310.pyc
Normal file
BIN
backend/mesa/__pycache__/urls.cpython-310.pyc
Normal file
Binary file not shown.
BIN
backend/mesa/__pycache__/urls.cpython-312.pyc
Normal file
BIN
backend/mesa/__pycache__/urls.cpython-312.pyc
Normal file
Binary file not shown.
BIN
backend/mesa/__pycache__/views.cpython-310.pyc
Normal file
BIN
backend/mesa/__pycache__/views.cpython-310.pyc
Normal file
Binary file not shown.
BIN
backend/mesa/__pycache__/wsgi.cpython-310.pyc
Normal file
BIN
backend/mesa/__pycache__/wsgi.cpython-310.pyc
Normal file
Binary file not shown.
BIN
backend/mesa/__pycache__/wsgi.cpython-312.pyc
Normal file
BIN
backend/mesa/__pycache__/wsgi.cpython-312.pyc
Normal file
Binary file not shown.
28
backend/mesa/asgi.py
Normal file
28
backend/mesa/asgi.py
Normal file
@@ -0,0 +1,28 @@
|
||||
"""
|
||||
ASGI config for mesa project.
|
||||
|
||||
It exposes the ASGI callable as a module-level variable named ``application``.
|
||||
|
||||
For more information on this file, see
|
||||
https://docs.djangoproject.com/en/5.0/howto/deployment/asgi/
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
from django.core.asgi import get_asgi_application
|
||||
from channels.routing import ProtocolTypeRouter, URLRouter
|
||||
from channels.auth import AuthMiddlewareStack
|
||||
from channels.security.websocket import AllowedHostsOriginValidator
|
||||
import websocket.routing
|
||||
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mesa.settings')
|
||||
|
||||
application = ProtocolTypeRouter({
|
||||
'http':get_asgi_application(),
|
||||
"websocket": AllowedHostsOriginValidator(
|
||||
AuthMiddlewareStack(
|
||||
URLRouter(websocket.routing.websocket_urlpatterns)
|
||||
)
|
||||
|
||||
)
|
||||
})
|
||||
168
backend/mesa/settings.py
Normal file
168
backend/mesa/settings.py
Normal file
@@ -0,0 +1,168 @@
|
||||
"""
|
||||
Django settings for mesa project.
|
||||
|
||||
Generated by 'django-admin startproject' using Django 5.0.1.
|
||||
|
||||
For more information on this file, see
|
||||
https://docs.djangoproject.com/en/5.0/topics/settings/
|
||||
|
||||
For the full list of settings and their values, see
|
||||
https://docs.djangoproject.com/en/5.0/ref/settings/
|
||||
"""
|
||||
|
||||
from pathlib import Path
|
||||
import os
|
||||
|
||||
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
||||
BASE_DIR = Path(__file__).resolve().parent.parent
|
||||
|
||||
|
||||
# penis
|
||||
# Quick-start development settings - unsuitable for production
|
||||
# See https://docs.djangoproject.com/en/5.0/howto/deployment/checklist/
|
||||
|
||||
# SECURITY WARNING: keep the secret key used in production secret!
|
||||
SECRET_KEY = "django-insecure-1l2qso*l-)jo1@m9qn-itee_bm8(kdk_cx#$=9z-v18fjm-5p%"
|
||||
|
||||
# SECURITY WARNING: don't run with debug turned on in production!
|
||||
DEBUG = True
|
||||
|
||||
ALLOWED_HOSTS = ['0.0.0.0']
|
||||
|
||||
|
||||
# Application definition
|
||||
|
||||
INSTALLED_APPS = [
|
||||
"channels",
|
||||
|
||||
"django.contrib.admin",
|
||||
"django.contrib.auth",
|
||||
"django.contrib.contenttypes",
|
||||
"django.contrib.sessions",
|
||||
"django.contrib.messages",
|
||||
"django.contrib.staticfiles",
|
||||
# Third Party
|
||||
"rest_framework",
|
||||
"rest_framework.authtoken",
|
||||
'corsheaders',
|
||||
# Own
|
||||
"homepage",
|
||||
# "frontend.apps.FrontendConfig",
|
||||
"rest",
|
||||
"hub",
|
||||
"websocket",
|
||||
"frontend",
|
||||
]
|
||||
|
||||
ASGI_APPLICATION = "mesa.asgi.application"
|
||||
|
||||
MIDDLEWARE = [
|
||||
"django.middleware.security.SecurityMiddleware",
|
||||
"django.contrib.sessions.middleware.SessionMiddleware",
|
||||
"django.middleware.common.CommonMiddleware",
|
||||
"django.middleware.csrf.CsrfViewMiddleware",
|
||||
"django.contrib.auth.middleware.AuthenticationMiddleware",
|
||||
"django.contrib.messages.middleware.MessageMiddleware",
|
||||
"django.middleware.clickjacking.XFrameOptionsMiddleware",
|
||||
'corsheaders.middleware.CorsMiddleware',
|
||||
]
|
||||
|
||||
SESSION_ENGINE = "django.contrib.sessions.backends.db"
|
||||
|
||||
|
||||
ROOT_URLCONF = "mesa.urls"
|
||||
|
||||
TEMPLATES = [
|
||||
{
|
||||
"BACKEND": "django.template.backends.django.DjangoTemplates",
|
||||
"DIRS": [],
|
||||
"APP_DIRS": True,
|
||||
"OPTIONS": {
|
||||
"context_processors": [
|
||||
"django.template.context_processors.debug",
|
||||
"django.template.context_processors.request",
|
||||
"django.contrib.auth.context_processors.auth",
|
||||
"django.contrib.messages.context_processors.messages",
|
||||
],
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
WSGI_APPLICATION = "mesa.wsgi.application"
|
||||
|
||||
# Redis configuration for WebSocket communication
|
||||
CHANNEL_LAYERS = {
|
||||
"default": {
|
||||
"BACKEND": "channels_redis.core.RedisChannelLayer",
|
||||
"CONFIG": {
|
||||
"hosts": [("127.0.0.1", 6379)], # Replace with your Redis server details
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
# Database
|
||||
# https://docs.djangoproject.com/en/5.0/ref/settings/#databases
|
||||
|
||||
DATABASES = {
|
||||
"default": {
|
||||
"ENGINE": "django.db.backends.sqlite3",
|
||||
"NAME": BASE_DIR / "db.sqlite3",
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
# Password validation
|
||||
# https://docs.djangoproject.com/en/5.0/ref/settings/#auth-password-validators
|
||||
|
||||
AUTH_PASSWORD_VALIDATORS = [
|
||||
{
|
||||
"NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator",
|
||||
},
|
||||
{
|
||||
"NAME": "django.contrib.auth.password_validation.MinimumLengthValidator",
|
||||
},
|
||||
{
|
||||
"NAME": "django.contrib.auth.password_validation.CommonPasswordValidator",
|
||||
},
|
||||
{
|
||||
"NAME": "django.contrib.auth.password_validation.NumericPasswordValidator",
|
||||
},
|
||||
]
|
||||
|
||||
|
||||
# I love you Lucas <3
|
||||
# Internationalization
|
||||
# https://docs.djangoproject.com/en/5.0/topics/i18n/
|
||||
|
||||
LANGUAGE_CODE = "en-us"
|
||||
|
||||
TIME_ZONE = "UTC"
|
||||
|
||||
USE_I18N = True
|
||||
|
||||
USE_TZ = True
|
||||
|
||||
|
||||
# Static files (CSS, JavaScript, Images)
|
||||
# https://docs.djangoproject.com/en/5.0/howto/static-files/
|
||||
|
||||
STATIC_URL = "static/"
|
||||
STATICFILES_DIRS = [os.path.join(BASE_DIR, "static")]
|
||||
|
||||
# Default primary key field type
|
||||
# https://docs.djangoproject.com/en/5.0/ref/settings/#default-auto-field
|
||||
|
||||
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
|
||||
|
||||
REST_FRAMEWORK = {
|
||||
"DEFAULT_PAGINATION_CLASS": "rest_framework.pagination.PageNumberPagination",
|
||||
"PAGE_SIZE": 10,
|
||||
}
|
||||
|
||||
MEDIA_URL = '/media/'
|
||||
MEDIA_ROOT = BASE_DIR / 'media'
|
||||
|
||||
CORS_ALLOWED_ORIGINS = [
|
||||
"http://localhost:3000", # React's Dev Server
|
||||
]
|
||||
47
backend/mesa/urls.py
Normal file
47
backend/mesa/urls.py
Normal file
@@ -0,0 +1,47 @@
|
||||
"""
|
||||
URL configuration for mesa project.
|
||||
|
||||
The `urlpatterns` list routes URLs to views. For more information please see:
|
||||
https://docs.djangoproject.com/en/5.0/topics/http/urls/
|
||||
Examples:
|
||||
Function views
|
||||
1. Add an import: from my_app import views
|
||||
2. Add a URL to urlpatterns: path('', views.home, name='home')
|
||||
Class-based views
|
||||
1. Add an import: from other_app.views import Home
|
||||
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
|
||||
Including another URLconf
|
||||
1. Import the include() function: from django.urls import include, path
|
||||
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
|
||||
"""
|
||||
from rest_framework import routers
|
||||
from django.conf.urls.static import static
|
||||
from django.conf import settings
|
||||
|
||||
from django.contrib import admin
|
||||
from django.urls import path, include
|
||||
from homepage import views as homepageViews
|
||||
from rest import views as restViews
|
||||
from django.urls import re_path
|
||||
from rest import views
|
||||
|
||||
router = routers.DefaultRouter()
|
||||
# router.register(r'users', restViews.UserViewSet)
|
||||
|
||||
urlpatterns = [
|
||||
path('admin/', admin.site.urls),
|
||||
# path("", homepageViews.index, name="index"),
|
||||
path("rest/", include(router.urls)),
|
||||
path('api_auth/', include("rest_framework.urls", namespace="rest_framework")),
|
||||
path("", include("frontend.urls")),
|
||||
re_path("account_creation/", views.signup),
|
||||
re_path("login/", views.loginReq),
|
||||
re_path("gethubs", views.list_user_hubs),
|
||||
re_path("getspecifichub", views.list_specific_hub),
|
||||
re_path("postMessage", views.post_Message_To_Hub),
|
||||
re_path("getHubChannels", views.list_channel_hubs),
|
||||
re_path("getSpecificChannel", views.list_specific_channel_hub),
|
||||
]
|
||||
|
||||
urlpatterns += router.urls
|
||||
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
||||
16
backend/mesa/wsgi.py
Normal file
16
backend/mesa/wsgi.py
Normal file
@@ -0,0 +1,16 @@
|
||||
"""
|
||||
WSGI config for mesa project.
|
||||
|
||||
It exposes the WSGI callable as a module-level variable named ``application``.
|
||||
|
||||
For more information on this file, see
|
||||
https://docs.djangoproject.com/en/5.0/howto/deployment/wsgi/
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
from django.core.wsgi import get_wsgi_application
|
||||
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mesa.settings')
|
||||
|
||||
application = get_wsgi_application()
|
||||
Reference in New Issue
Block a user