Parcourir la source

Update of expe page example

Jérôme BUISINE il y a 4 ans
Parent
commit
5c75fc225d

+ 40 - 0
README.md

@@ -0,0 +1,40 @@
+# DjangoRecipes
+
+## Description
+
+Web site which contains experiences on synthesis images (perception of noise). 
+
+## Installation
+
+## Requirements
+
+You need to have python, pip
+
+```
+pip install -r requirements.txt
+```
+
+## Run server
+
+And then, run the server :
+
+```
+python project/manage.py runserver
+```
+
+or if you want to precise a specific port number :
+
+```
+python project/manage.py runserver 8080
+```
+
+
+## How to contribute ?
+
+This project uses [git-flow](https://danielkummer.github.io/git-flow-cheatsheet/) to improve cooperation during the development.
+
+For each feature, you have to create a new git flow feature branch.
+
+## Licence
+
+[MIT](LICENSE)

BIN
ThesisWebExpeDjango/__pycache__/__init__.cpython-36.pyc


BIN
ThesisWebExpeDjango/__pycache__/settings.cpython-36.pyc


+ 5 - 0
ThesisWebExpeDjango/settings.py

@@ -37,6 +37,7 @@ INSTALLED_APPS = [
     'django.contrib.sessions',
     'django.contrib.messages',
     'django.contrib.staticfiles',
+    'expe'
 ]
 
 MIDDLEWARE = [
@@ -118,3 +119,7 @@ USE_TZ = True
 # https://docs.djangoproject.com/en/2.2/howto/static-files/
 
 STATIC_URL = '/static/'
+
+STATICFILES_DIRS = (
+    os.path.join(BASE_DIR, 'static'),
+)

+ 27 - 0
expe/templates/expe/base.html

@@ -0,0 +1,27 @@
+<!DOCTYPE html>
+<html lang="fr">
+<head>
+    <meta charset="UTF-8"/>
+    <title>
+        {% block title %}
+
+        {% endblock %}
+    </title>
+
+    {% load staticfiles %}
+    {% block stylesheets %}
+        <link rel="stylesheet" type="text/css" href="{% static "css/expe.css" %}">
+    {% endblock %}
+</head>
+<body>
+
+    <div class="container">
+    {% block content %}
+        
+    {% endblock %}
+    </div>
+
+    {% block javascripts %}
+        <script src="{% static "js/loadImg.js" %}"/>
+    {% endblock %}
+</body>

+ 12 - 0
expe/templates/expe/expe.html

@@ -0,0 +1,12 @@
+{% extends 'expe/base.html' %}
+
+{% block title %}
+    Expe {{ expe_name }}
+{% endblock %}
+
+{% block content %}
+    <p>Display reconstructed image here</p>
+
+    <!-- TODO : Load img from bitmap with javascript `loadImg.js` -->
+    <img src="{{ link1 }}"/>
+{% endblock %}

+ 1 - 1
expe/urls.py

@@ -4,5 +4,5 @@ from django.urls import path
 from . import views
 
 urlpatterns = [
-    path('', views.index, name='index'),
+    path('', views.expe, name='expe'),
 ]

+ 4 - 2
expe/views.py

@@ -3,5 +3,7 @@ from django.http import HttpResponse
 
 # Create your views here.
 
-def index(request):
-    return HttpResponse("Hello, world. You're at the polls index.")
+def expe(request):
+
+    link1 = 'http://diran.univ-littoral.fr/api/images/bathroom/bathroom_00200.png'
+    return render(request, 'expe/expe.html', {'expe_name': 'test_expe', 'link1': link1})

+ 1 - 0
requirement.txt

@@ -0,0 +1 @@
+Django

+ 8 - 0
static/css/expe.css

@@ -0,0 +1,8 @@
+body {
+    background-color: grey;
+}
+
+.container{
+    margin-top: 5%;
+    text-align: center;
+}

+ 5 - 0
static/js/loadImg.js

@@ -0,0 +1,5 @@
+// https://stackoverflow.com/questions/20756042/javascript-how-to-display-image-from-byte-array-using-javascript-or-servlet
+
+window.onload = function () {
+    console.log('Load img here...');
+}