From ab27138102a204bd62731f2b59cc5399358b07c1 Mon Sep 17 00:00:00 2001 From: Jacek Lebioda <jacek.lebioda.001@student.uni.lu> Date: Wed, 9 Nov 2016 14:19:11 +0100 Subject: [PATCH] Basic web application --- smash/smash/settings.py | 28 ---------------------------- smash/smash/urls.py | 6 +++++- smash/web/static/.touch | 0 smash/web/templates/_base.html | 25 +++++++++++++++++++++++++ smash/web/templates/index.html | 5 +++++ smash/web/urls.py | 21 +++++++++++++++++++++ smash/web/views.py | 7 +++++++ 7 files changed, 63 insertions(+), 29 deletions(-) create mode 100644 smash/web/static/.touch create mode 100644 smash/web/templates/_base.html create mode 100644 smash/web/templates/index.html create mode 100644 smash/web/urls.py diff --git a/smash/smash/settings.py b/smash/smash/settings.py index f9736f16..327f508e 100644 --- a/smash/smash/settings.py +++ b/smash/smash/settings.py @@ -62,34 +62,6 @@ TEMPLATES = [ }, ] - -# SECURITY WARNING: keep the secret key used in production secret! -SECRET_KEY = '@u6t&w7yw&i!dcrm97y1bg*pt9e@s240dc@*b6d9_#b^bqr%+^' - -# SECURITY WARNING: don't run with debug turned on in production! -DEBUG = True - -WSGI_APPLICATION = 'smash.wsgi.application' - - -# Database -# https://docs.djangoproject.com/en/1.10/ref/settings/#databases - -DATABASES = { - 'default': { - 'ENGINE': 'django.db.backends.postgresql_psycopg2', - 'NAME': 'smashdb', - 'PASSWORD': '---', - 'HOST': 'localhost', - 'PORT': '' # '' === default one - - # If to use sqlite - # 'ENGINE': 'django.db.backends.sqlite3', - # 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), - } -} - - # Password validation # https://docs.djangoproject.com/en/1.10/ref/settings/#auth-password-validators diff --git a/smash/smash/urls.py b/smash/smash/urls.py index c2a2104d..b26bd979 100644 --- a/smash/smash/urls.py +++ b/smash/smash/urls.py @@ -13,9 +13,13 @@ Including another URLconf 1. Import the include() function: from django.conf.urls import url, include 2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls')) """ -from django.conf.urls import url + +from django.conf.urls import url, include from django.contrib import admin +import web.urls + urlpatterns = [ url(r'^admin/', admin.site.urls), + url(r'^', include(web.urls)) ] diff --git a/smash/web/static/.touch b/smash/web/static/.touch new file mode 100644 index 00000000..e69de29b diff --git a/smash/web/templates/_base.html b/smash/web/templates/_base.html new file mode 100644 index 00000000..b7448329 --- /dev/null +++ b/smash/web/templates/_base.html @@ -0,0 +1,25 @@ +{% load static %} +<!DOCTYPE html> +<html lang="en"> +<head> + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> + <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0"/> + <title>{% block title %}Scheduling system{% endblock title %}</title> + + {% block styles %} + <!-- links rel=stylesheet here --> + {% endblock styles %} +</head> +<body> + {% block content %} + {% endblock content %} + + + {% block footer %} + {% endblock footer %} + + {% block scripts %} + <script src="https://code.jquery.com/jquery-2.1.1.min.js"></script> + {% endblock scripts %} +</body> +</html> diff --git a/smash/web/templates/index.html b/smash/web/templates/index.html new file mode 100644 index 00000000..5e1abb2c --- /dev/null +++ b/smash/web/templates/index.html @@ -0,0 +1,5 @@ +{% extends "_base.html" %} + +{% block content %} + <h3>Smart scheduling</h3> +{% endblock content %} diff --git a/smash/web/urls.py b/smash/web/urls.py new file mode 100644 index 00000000..becbb07e --- /dev/null +++ b/smash/web/urls.py @@ -0,0 +1,21 @@ +"""smash URL Configuration + +The `urlpatterns` list routes URLs to views. For more information please see: + https://docs.djangoproject.com/en/1.10/topics/http/urls/ +Examples: +Function views + 1. Add an import: from my_app import views + 2. Add a URL to urlpatterns: url(r'^$', views.home, name='home') +Class-based views + 1. Add an import: from other_app.views import Home + 2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home') +Including another URLconf + 1. Import the include() function: from django.conf.urls import url, include + 2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls')) +""" +from django.conf.urls import url +from web import views + +urlpatterns = [ + url(r'$', views.index) +] diff --git a/smash/web/views.py b/smash/web/views.py index 91ea44a2..27371906 100644 --- a/smash/web/views.py +++ b/smash/web/views.py @@ -1,3 +1,10 @@ from django.shortcuts import render +from django.http import HttpResponse +from django.template import loader + # Create your views here. +def index(request): + template = loader.get_template("index.html") + return HttpResponse(template.render({}), request) + -- GitLab