Rutas de error
This commit is contained in:
0
views/__init__.py
Normal file
0
views/__init__.py
Normal file
7
views/apps.py
Normal file
7
views/apps.py
Normal file
@@ -0,0 +1,7 @@
|
||||
"""Definición de la configuración de la app"""
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class ViewsConfig(AppConfig):
|
||||
"""Configuración de Views"""
|
||||
name = 'views'
|
||||
29
views/static/views/css/base.css
Normal file
29
views/static/views/css/base.css
Normal file
@@ -0,0 +1,29 @@
|
||||
:root {
|
||||
--background-color: hsl(10, 20%, 98%);
|
||||
--foreground-color: hsl(10, 10%, 13%);
|
||||
--primary-color: hsl(284, 30%, 40%);
|
||||
--highlight-color: hsl(290, 86%, 43%);
|
||||
--light-color: hsl(10, 10%, 40%);
|
||||
--error-color: hsl(0, 100%, 60%)
|
||||
}
|
||||
|
||||
html, body {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
body {
|
||||
background-color: var(--background-color);
|
||||
color: var(--foreground-color);
|
||||
overflow-y: scroll;
|
||||
font-family: sans-serif;
|
||||
}
|
||||
|
||||
main {
|
||||
max-width: 80ch;
|
||||
margin: 25vh auto;
|
||||
}
|
||||
|
||||
a {
|
||||
color: var(--highlight-color)
|
||||
}
|
||||
|
||||
4
views/static/views/css/normalize.css
vendored
Normal file
4
views/static/views/css/normalize.css
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
/******************************************************************************
|
||||
=> NORMALIZE.CSS
|
||||
*******************************************************************************/
|
||||
button,hr,input{overflow:visible}progress,sub,sup{vertical-align:baseline}[type=checkbox],[type=radio],legend{box-sizing:border-box;padding:0}html{line-height:1.15;-webkit-text-size-adjust:100%}body{margin:0}details,main{display:block}h1{font-size:2em;margin:.67em 0}hr{box-sizing:content-box;height:0}a{background-color:transparent}abbr[title]{border-bottom:none;text-decoration:underline;text-decoration:underline dotted}b,strong{font-weight:bolder}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}img{border-style:none}button,input,optgroup,select,textarea{font-family:inherit;font-size:100%;line-height:1.15;margin:0}button,select{text-transform:none}[type=button],[type=reset],[type=submit],button{-webkit-appearance:button}[type=button]::-moz-focus-inner,[type=reset]::-moz-focus-inner,[type=submit]::-moz-focus-inner,button::-moz-focus-inner{border-style:none;padding:0}[type=button]:-moz-focusring,[type=reset]:-moz-focusring,[type=submit]:-moz-focusring,button:-moz-focusring{outline:ButtonText dotted 1px}fieldset{padding:.35em .75em .625em}legend{color:inherit;display:table;max-width:100%;white-space:normal}textarea{overflow:auto}[type=number]::-webkit-inner-spin-button,[type=number]::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}[type=search]::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}[hidden],template{display:none}
|
||||
22
views/templates/views/index.html
Normal file
22
views/templates/views/index.html
Normal file
@@ -0,0 +1,22 @@
|
||||
{% load static %}
|
||||
<!DOCTYPE html>
|
||||
<html lang="es">
|
||||
<head>
|
||||
<title>{% block title %}MusicList{% endblock %}</title>
|
||||
<link rel="stylesheet" type="text/css" href="{% static "views/css/normalize.css" %}">
|
||||
<link rel="stylesheet" type="text/css" href="{% static "views/css/base.css" %}">
|
||||
{% block extrastyle %}{% endblock %}
|
||||
{% block extrahead %}{% endblock %}
|
||||
{% block responsive %}
|
||||
<meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1.0, maximum-scale=1.0">
|
||||
{% endblock %}
|
||||
</head>
|
||||
<body>
|
||||
<main>
|
||||
<h1>Hey no deberías estar aquí!</h1>
|
||||
<p>Esto esta en desarrollo, esta es la api para una sexy aplicación con la que se podrá organizar musica
|
||||
muy al estilo de <a href="https://www.myanimelist.net">MyAnimeList</a> pero claro, con musica.</p>
|
||||
<p>Algún dia estará terminada :3</p>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
7
views/urls.py
Normal file
7
views/urls.py
Normal file
@@ -0,0 +1,7 @@
|
||||
"""Definición de urls de la aplicación"""
|
||||
from django.urls import path
|
||||
from views import views
|
||||
|
||||
urlpatterns = [
|
||||
path('', views.index)
|
||||
]
|
||||
37
views/views.py
Normal file
37
views/views.py
Normal file
@@ -0,0 +1,37 @@
|
||||
import json
|
||||
|
||||
from django.core.serializers.json import DjangoJSONEncoder
|
||||
from django.http import HttpResponseNotFound
|
||||
from django.shortcuts import render
|
||||
|
||||
|
||||
def index(request):
|
||||
"""Vista de index"""
|
||||
return render(request, 'views/index.html')
|
||||
|
||||
|
||||
def _handle_error(status, error):
|
||||
"""Vista general de error"""
|
||||
response = {'status': status, 'error': error}
|
||||
encoded = json.dumps(response, cls=DjangoJSONEncoder)
|
||||
return HttpResponseNotFound(encoded, content_type='application/json')
|
||||
|
||||
|
||||
def handle400(request, exception=None):
|
||||
"""Vista de error 400"""
|
||||
return _handle_error(400, 'La request realizada es errónea')
|
||||
|
||||
|
||||
def handle403(request, exception=None):
|
||||
"""Vista de error 404"""
|
||||
return _handle_error(404, 'No se tiene permiso para acceder')
|
||||
|
||||
|
||||
def handle404(request, exception=None):
|
||||
"""Vista de error 404"""
|
||||
return _handle_error(404, 'El recurso buscado no existe')
|
||||
|
||||
|
||||
def handle500(request, exception=None):
|
||||
"""Vista de error 500"""
|
||||
return _handle_error(500, 'Error del servidor')
|
||||
Reference in New Issue
Block a user