💄 add index viex for web app

pull/3/head
Axel DE LA FUENTE 1 year ago
parent 80418083e5
commit 53ce483fff

@ -2,3 +2,4 @@ scikit-learn
matplotlib
numpy
pandas
Django

@ -54,7 +54,7 @@ ROOT_URLCONF = 'app.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'DIRS': ["./src/html/"],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [

@ -4,4 +4,3 @@ class SrcConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'src'

@ -0,0 +1,8 @@
from django import forms
from .models import Text
class TextForm(forms.ModelForm):
class Meta:
model = Text
fields = ['title', 'url']

@ -0,0 +1,66 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>FakeNews</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
{% load static %}
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Fira+Code:wght@700&display=swap" rel="stylesheet">
<style>
body, html {height: 100%}
h1, h4, span, label, button {font-family: 'Fira Code', monospace;}
.credit{position: absolute; bottom:0; right:0; margin:.5rem;}
form > div{margin:.5rem;}
form{
display: flex;
justify-content: center;
}
button{
font-size: 16px;
letter-spacing: 2px;
text-decoration: none;
text-transform: uppercase;
background-color: white;
cursor: pointer;
border: 3px solid;
padding: 0.25em 0.5em;
box-shadow: 1px 1px 0px 0px, 2px 2px 0px 0px, 3px 3px 0px 0px, 4px 4px 0px 0px, 5px 5px 0px 0px;
position: relative;
user-select: none;
-webkit-user-select: none;
touch-action: manipulation;
}
button:active {
box-shadow: 0px 0px 0px 0px;
top: 5px;
left: 5px;
}
</style>
</head>
<body>
<div class="w3-animate-opacity">
<div class="w3-display-middle">
<h1 class="w3-jumbo w3-animate-top">Fake News Detector</h1>
<h4>Enter title and url of the news:</h4>
<form method="post">
{% csrf_token %}
{{ form }}
<button type="submit">Is it fake ??</button>
</form>
</div>
</div>
<span class="credit">by: LIVET Hugo & DE LA FUENTE Axel</span>
</body>
</html>

@ -1,3 +1,14 @@
from django.db import models
# Create your models here.
class Text(models.Model):
title = models.CharField(max_length=100)
url = models.URLField()
class Meta:
app_label = 'app'
def __str__(self):
return self.title

@ -1,11 +1,15 @@
from django.shortcuts import render
from django.shortcuts import render, redirect
# Create your views here.
from django.http import HttpResponse
from .forms import TextForm
def index(request):
return HttpResponse("Hello, world. You're at the polls index.")
if request.method == 'POST':
form = TextForm(request.POST)
if form.is_valid():
title = form.cleaned_data["title"]
url = form.cleaned_data["url"]
return redirect("index") # Rediriger vers une page d'accueil ou une autre vue
else:
form = TextForm()
return render(request, 'home.html', {'form': form})

Loading…
Cancel
Save