Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b2eb62c102 | ||
|
|
1cd8089d8d |
Generated
-17
@@ -1,17 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="PYTHON_MODULE" version="4">
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="module" module-name="dghj" />
|
||||
<orderEntry type="module" module-name="untitled" />
|
||||
<orderEntry type="module" module-name="untitled1" />
|
||||
<orderEntry type="module" module-name="untitled1" />
|
||||
<orderEntry type="module" module-name="django_project" />
|
||||
</component>
|
||||
<component name="TestRunnerService">
|
||||
<option name="projectConfiguration" value="py.test" />
|
||||
<option name="PROJECT_TEST_RUNNER" value="py.test" />
|
||||
</component>
|
||||
</module>
|
||||
Generated
-4
@@ -1,4 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.6 (untitled)" project-jdk-type="Python SDK" />
|
||||
</project>
|
||||
Generated
-12
@@ -1,12 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/MEIM.iml" filepath="$PROJECT_DIR$/.idea/MEIM.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/../dghj/.idea/dghj.iml" filepath="$PROJECT_DIR$/../dghj/.idea/dghj.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/django_project/.idea/django_project.iml" filepath="$PROJECT_DIR$/django_project/.idea/django_project.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/../untitled/.idea/untitled.iml" filepath="$PROJECT_DIR$/../untitled/.idea/untitled.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/../prakt3_django/.idea/untitled1.iml" filepath="$PROJECT_DIR$/../prakt3_django/.idea/untitled1.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
||||
Generated
-6
@@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
@@ -1,20 +0,0 @@
|
||||
import socket
|
||||
import string
|
||||
|
||||
s = socket.socket()
|
||||
host = socket.gethostname()
|
||||
port = 21345
|
||||
s.bind((host, port))
|
||||
s.listen()
|
||||
|
||||
while True:
|
||||
(connection, addr) = s.accept()
|
||||
print('Verbindung von ', addr)
|
||||
msg = 'Server sagt Hallo'
|
||||
connection.send(msg.encode('utf-8'))
|
||||
msg = connection.recv(1024)
|
||||
msg = (msg.decode('utf-8')).upper()
|
||||
connection.send(msg.encode('utf-8'))
|
||||
#msg = msg.decode('utf-8')
|
||||
#print(msg)
|
||||
connection.close()
|
||||
Generated
-31
@@ -1,31 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="PYTHON_MODULE" version="4">
|
||||
<component name="FacetManager">
|
||||
<facet type="django" name="Django">
|
||||
<configuration>
|
||||
<option name="rootFolder" value="$MODULE_DIR$" />
|
||||
<option name="settingsModule" value="djp/settings.py" />
|
||||
<option name="manageScript" value="$MODULE_DIR$/manage.py" />
|
||||
<option name="environment" value="<map/>" />
|
||||
<option name="doNotUseTestRunner" value="false" />
|
||||
</configuration>
|
||||
</facet>
|
||||
</component>
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
<component name="TemplatesService">
|
||||
<option name="TEMPLATE_CONFIGURATION" value="Django" />
|
||||
<option name="TEMPLATE_FOLDERS">
|
||||
<list>
|
||||
<option value="$MODULE_DIR$/templates" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="TestRunnerService">
|
||||
<option name="projectConfiguration" value="py.test" />
|
||||
<option name="PROJECT_TEST_RUNNER" value="py.test" />
|
||||
</component>
|
||||
</module>
|
||||
Generated
-4
@@ -1,4 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.6 (untitled)" project-jdk-type="Python SDK" />
|
||||
</project>
|
||||
Generated
-8
@@ -1,8 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/djp.iml" filepath="$PROJECT_DIR$/.idea/djp.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
||||
Generated
-6
@@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
@@ -1,125 +0,0 @@
|
||||
"""
|
||||
Django settings for djp project.
|
||||
|
||||
Generated by 'django-admin startproject' using Django 2.1.2.
|
||||
|
||||
For more information on this file, see
|
||||
https://docs.djangoproject.com/en/2.1/topics/settings/
|
||||
|
||||
For the full list of settings and their values, see
|
||||
https://docs.djangoproject.com/en/2.1/ref/settings/
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
|
||||
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
|
||||
|
||||
# Quick-start development settings - unsuitable for production
|
||||
# See https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/
|
||||
|
||||
# SECURITY WARNING: keep the secret key used in production secret!
|
||||
SECRET_KEY = '83_2_@62*!7v6ucotsg$mhznlc0prw%tb!i*w--1dvk@52+b(+'
|
||||
|
||||
# SECURITY WARNING: don't run with debug turned on in production!
|
||||
DEBUG = True
|
||||
|
||||
ALLOWED_HOSTS = []
|
||||
|
||||
|
||||
# Application definition
|
||||
|
||||
INSTALLED_APPS = [
|
||||
'rest_framework',
|
||||
'django.contrib.admin',
|
||||
'django.contrib.auth',
|
||||
'django.contrib.contenttypes',
|
||||
'django.contrib.sessions',
|
||||
'django.contrib.messages',
|
||||
'django.contrib.staticfiles',
|
||||
'polls.apps.PollsConfig',
|
||||
]
|
||||
|
||||
|
||||
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',
|
||||
]
|
||||
|
||||
ROOT_URLCONF = 'djp.urls'
|
||||
|
||||
TEMPLATES = [
|
||||
{
|
||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||
'DIRS': [os.path.join(BASE_DIR, 'templates')]
|
||||
,
|
||||
'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 = 'djp.wsgi.application'
|
||||
|
||||
|
||||
# Database
|
||||
# https://docs.djangoproject.com/en/2.1/ref/settings/#databases
|
||||
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.sqlite3',
|
||||
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
# Password validation
|
||||
# https://docs.djangoproject.com/en/2.1/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',
|
||||
},
|
||||
]
|
||||
|
||||
|
||||
# Internationalization
|
||||
# https://docs.djangoproject.com/en/2.1/topics/i18n/
|
||||
|
||||
LANGUAGE_CODE = 'de-de'
|
||||
|
||||
TIME_ZONE = 'UTC'
|
||||
|
||||
USE_I18N = True
|
||||
|
||||
USE_L10N = True
|
||||
|
||||
USE_TZ = True
|
||||
|
||||
|
||||
# Static files (CSS, JavaScript, Images)
|
||||
# https://docs.djangoproject.com/en/2.1/howto/static-files/
|
||||
|
||||
STATIC_URL = '/static/'
|
||||
@@ -1,23 +0,0 @@
|
||||
"""djp URL Configuration
|
||||
|
||||
The `urlpatterns` list routes URLs to views. For more information please see:
|
||||
https://docs.djangoproject.com/en/2.1/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 django.conf.urls import url, include
|
||||
from django.contrib import admin
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^polls/', include('polls.urls')),
|
||||
url('accounts/', include('django.contrib.auth.urls')),
|
||||
url(r'^admin/', admin.site.urls),
|
||||
]
|
||||
@@ -1,16 +0,0 @@
|
||||
"""
|
||||
WSGI config for djp 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/2.1/howto/deployment/wsgi/
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
from django.core.wsgi import get_wsgi_application
|
||||
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'djp.settings')
|
||||
|
||||
application = get_wsgi_application()
|
||||
@@ -1,15 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
import os
|
||||
import sys
|
||||
|
||||
if __name__ == '__main__':
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'djp.settings')
|
||||
try:
|
||||
from django.core.management import execute_from_command_line
|
||||
except ImportError as exc:
|
||||
raise ImportError(
|
||||
"Couldn't import Django. Are you sure it's installed and "
|
||||
"available on your PYTHONPATH environment variable? Did you "
|
||||
"forget to activate a virtual environment?"
|
||||
) from exc
|
||||
execute_from_command_line(sys.argv)
|
||||
@@ -1,3 +0,0 @@
|
||||
from django.contrib import admin
|
||||
|
||||
# Register your models here.
|
||||
@@ -1,5 +0,0 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class PollsConfig(AppConfig):
|
||||
name = 'polls'
|
||||
@@ -1,9 +0,0 @@
|
||||
from django import forms
|
||||
import datetime
|
||||
|
||||
class NoticeForm(forms.Form):
|
||||
date_formats = ['%d.%m.%Y', '%d.%m.%y']
|
||||
title = forms.CharField(label='Titel', max_length=80)
|
||||
text = forms.CharField(label='Text', max_length=400)
|
||||
start = forms.DateField(label='Von', input_formats=date_formats, initial=datetime.date.today)
|
||||
end = forms.DateField(label='Bis', input_formats=date_formats, initial=datetime.date.today)
|
||||
@@ -1,24 +0,0 @@
|
||||
# Generated by Django 2.1.3 on 2018-11-12 15:06
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Notice',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('notice_title', models.CharField(max_length=80)),
|
||||
('notice_text', models.CharField(max_length=400)),
|
||||
('pub_start', models.DateTimeField()),
|
||||
('pub_end', models.DateTimeField()),
|
||||
],
|
||||
),
|
||||
]
|
||||
@@ -1,8 +0,0 @@
|
||||
from django.db import models
|
||||
|
||||
# Create your models here.
|
||||
class Notice(models.Model):
|
||||
notice_title = models.CharField(max_length=80)
|
||||
notice_text = models.CharField(max_length=400)
|
||||
pub_start = models.DateTimeField()
|
||||
pub_end = models.DateTimeField()
|
||||
@@ -1,7 +0,0 @@
|
||||
from rest_framework import serializers
|
||||
from .models import Notice
|
||||
|
||||
class NoticeSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = Notice
|
||||
fields = ('id', 'notice_title', 'notice_text', 'pub_start', 'pub_end')
|
||||
@@ -1,3 +0,0 @@
|
||||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
||||
@@ -1,15 +0,0 @@
|
||||
from django.conf.urls import url, include
|
||||
from django.urls import path
|
||||
|
||||
|
||||
|
||||
from . import views
|
||||
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^$', views.index, name='index'),
|
||||
url('new', views.new, name='new'),
|
||||
path('delete/<int:deleteId>', views.delete, name='delete'),
|
||||
path('notices/', views.notice_list),
|
||||
path('notices/<int:id>/', views.notice_detail),
|
||||
]
|
||||
@@ -1,83 +0,0 @@
|
||||
from django.http import HttpResponse, JsonResponse
|
||||
from django.shortcuts import render, redirect
|
||||
import time
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from django.contrib.admin.views.decorators import staff_member_required
|
||||
from polls.forms import NoticeForm
|
||||
from django.utils import timezone
|
||||
from datetime import timedelta
|
||||
from polls.models import Notice
|
||||
from polls.serializers import NoticeSerializer
|
||||
from rest_framework.renderers import JSONRenderer
|
||||
from rest_framework.parsers import JSONParser
|
||||
from django.views.decorators.csrf import csrf_exempt
|
||||
def index(request):
|
||||
context = {'now' : time.strftime('%H:%M:%S', time.localtime()),
|
||||
'posts' : Notice.objects.all() }
|
||||
# start = timezone.now()
|
||||
#end = start + timedelta(days=10)
|
||||
#for n in Notice.objects.all():
|
||||
# print(n.notice_title)
|
||||
return render(request, 'polls/index.html', context)
|
||||
|
||||
@csrf_exempt
|
||||
def notice_list(request):
|
||||
|
||||
if request.method == 'GET':
|
||||
notices = Notice.objects.all()
|
||||
serializer = NoticeSerializer(notices, many=True)
|
||||
return JsonResponse(serializer.data, safe=False)
|
||||
elif request.method == 'POST':
|
||||
data = JSONParser().parse(request)
|
||||
serializer = NoticeSerializer(data=data)
|
||||
if serializer.is_valid():
|
||||
serializer.save()
|
||||
return JsonResponse(serializer.data, status=201)
|
||||
return HttpResponse(status=405)
|
||||
|
||||
@csrf_exempt
|
||||
def notice_detail(request, id):
|
||||
|
||||
try:
|
||||
notice = Notice.objects.get(id=id)
|
||||
except:
|
||||
return HttpResponse(status=404)
|
||||
|
||||
if request.method == 'GET':
|
||||
serializer = NoticeSerializer(notice)
|
||||
return JsonResponse(serializer.data)
|
||||
|
||||
elif request.method == 'PUT':
|
||||
data = JSONParser().parse(request)
|
||||
serializer = NoticeSerializer(notice, data=data)
|
||||
if serializer.is_valid():
|
||||
serializer.save()
|
||||
return JsonResponse(serializer.data, status=201)
|
||||
return JsonResponse(serializer.errors, status=400)
|
||||
|
||||
elif request.method == 'DELETE':
|
||||
notice.delete()
|
||||
return HttpResponse(status=204)
|
||||
|
||||
return HttpResponse(status=405)
|
||||
|
||||
|
||||
@staff_member_required
|
||||
def delete(request, deleteId=None):
|
||||
if deleteId != None:
|
||||
deleteNotice = Notice.objects.get(id=deleteId)
|
||||
if deleteNotice != None:
|
||||
deleteNotice.delete()
|
||||
return redirect('index')
|
||||
|
||||
@login_required
|
||||
def new(request):
|
||||
if request.method == "POST":
|
||||
form = NoticeForm(request.POST)
|
||||
if form.is_valid():
|
||||
newNotice = Notice(notice_title=form.cleaned_data['title'],notice_text=form.cleaned_data['text'],pub_start=form.cleaned_data['start'],pub_end=form.cleaned_data['end'])
|
||||
newNotice.save()
|
||||
return redirect('index')
|
||||
context = {'form' : NoticeForm()}
|
||||
return render(request, 'polls/edit.html', context)
|
||||
# Create your views here.
|
||||
@@ -1,25 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>{% block title %} Platzhalter {% endblock %}</title>
|
||||
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
|
||||
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
|
||||
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
{% block navigation %}
|
||||
<nav class="navbar navbar-light bg-light">
|
||||
<a class="navbar-brand" href="https://www.google.de">go to Google</a>
|
||||
<a class="navbar-brand" href="https://www.th-nuernberg.de/">go to TH Ohm Homepage</a>
|
||||
</nav>
|
||||
{% endblock %}
|
||||
|
||||
{% block content %} Platzhalter {% endblock %}
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,20 +0,0 @@
|
||||
{% extends 'base.html' %}
|
||||
|
||||
{% block title %}
|
||||
edit
|
||||
{% endblock %}
|
||||
|
||||
|
||||
{% block content %}
|
||||
<h1>Neue Nachricht</h1>
|
||||
<form method="POST">
|
||||
{% csrf_token %}
|
||||
{{ form.as_p }}
|
||||
<button type="submit" class="save btn btn-default">Speichern</button>
|
||||
</form>
|
||||
{% endblock %}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
{% extends 'base.html' %}
|
||||
|
||||
{% block title %}
|
||||
Index
|
||||
{% endblock %}
|
||||
|
||||
|
||||
{% block content %}
|
||||
<div class="jumbotron jumbotron-fluid">
|
||||
<div class="container">
|
||||
<h1>Index der Polls-Applikation</h1>
|
||||
{% for post in posts %}
|
||||
<p>{{ post.notice_title }} {{ post.notice_text }}</p>
|
||||
<p><a href="{% url 'delete' deleteId=post.id %}" class="btn btn-info">delete message </a></p>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p><a href="{% url 'new' %}" class="btn btn-info" role="button">Neue Nachricht</a></p>
|
||||
|
||||
{% if user.is_authenticated %}
|
||||
<p><a href="{% url 'logout' %}?next=/polls"
|
||||
class="btn btn-warning">Abmelden</a></p>
|
||||
{% endif %}
|
||||
|
||||
{% endblock %}
|
||||
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
{% extends 'base.html' %}
|
||||
|
||||
{% block title %}
|
||||
Login
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<div class="container">
|
||||
|
||||
<form method="post" action="{% url 'login' %}">
|
||||
{% csrf_token %}
|
||||
Benutzername: {{ form.username }} <br>
|
||||
Passwort: {{ form.password }} <br>
|
||||
<button type="submit" class="btn btn-default">Anmelden</button>
|
||||
<input type="hidden" name="next" value="{{ next }}" />
|
||||
</form>
|
||||
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
||||
@@ -1,12 +0,0 @@
|
||||
import sys
|
||||
|
||||
def hashMod(bytes):
|
||||
result = 0
|
||||
for byte in bytes:
|
||||
result += byte
|
||||
return result % sys.maxsize
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_hashmod = hashMod("test".encode('utf-8'))
|
||||
print("Teste function hashMod : ", test_hashmod)
|
||||
@@ -1,6 +1,8 @@
|
||||
import pygame
|
||||
# init Spieldaten
|
||||
|
||||
pygame.init()
|
||||
myfont = pygame.font.SysFont('Comic Sans MS', 40)
|
||||
global running
|
||||
speed = 0
|
||||
|
||||
|
||||
@@ -60,9 +62,30 @@ def reflect_y():
|
||||
global speed_y
|
||||
speed_y *= -1
|
||||
|
||||
def game_over():
|
||||
global image_g_o
|
||||
screen.blit(image_g_o, (0, 0))
|
||||
def show_game_over():
|
||||
global image_g_o, screen, running
|
||||
screen.blit(image_g_o, (300, 100))
|
||||
textsurface = myfont.render('PONG', True, (0, 50, 200))
|
||||
screen.blit(textsurface, (500,80))
|
||||
textsurface = myfont.render('Press Space to restart - Escape to exit', True, (0, 50, 200))
|
||||
screen.blit(textsurface, (200, 500))
|
||||
pygame.display.flip()
|
||||
waiting = True
|
||||
while waiting:
|
||||
for event in pygame.event.get():
|
||||
if (event.type == pygame.QUIT):
|
||||
print('quit')
|
||||
waiting = False
|
||||
pygame.quit()
|
||||
running = False
|
||||
if event.type == pygame.KEYDOWN:
|
||||
if event.key == pygame.K_SPACE:
|
||||
print('space')
|
||||
waiting = False
|
||||
init_game()
|
||||
if event.key == pygame.K_ESCAPE:
|
||||
running = False
|
||||
pygame.quit()
|
||||
|
||||
def update():
|
||||
global x, y, width_player, height_player, speed, width, zaehler, height
|
||||
@@ -86,8 +109,8 @@ def update():
|
||||
image_rect.y += speed_y
|
||||
else:
|
||||
pass
|
||||
if image_rect.y == height and (zaehler%2 == 0):
|
||||
game_over()
|
||||
if image_rect.y >= height and (zaehler%2 == 0):
|
||||
show_game_over()
|
||||
|
||||
def draw():
|
||||
screen.fill(black)
|
||||
@@ -95,16 +118,19 @@ def draw():
|
||||
pygame.draw.rect(screen, red, rect)
|
||||
pygame.display.flip()
|
||||
|
||||
def init_game():
|
||||
global screen
|
||||
init()
|
||||
initRectangle()
|
||||
screen = pygame.display.set_mode(size)
|
||||
|
||||
pygame.init()
|
||||
init()
|
||||
initRectangle()
|
||||
screen = pygame.display.set_mode(size)
|
||||
|
||||
init_game()
|
||||
running = True
|
||||
|
||||
game_over = False
|
||||
|
||||
while running:
|
||||
if game_over:
|
||||
show_game_over()
|
||||
running = input()
|
||||
update()
|
||||
draw()
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
import socket
|
||||
|
||||
s = socket.socket()
|
||||
host = socket.gethostname()
|
||||
port = 21345
|
||||
|
||||
s.connect((host, port))
|
||||
bytes = s.recv(1024)
|
||||
print(bytes.decode('utf-8'))
|
||||
|
||||
msg = input('Hier Eingabe: ')
|
||||
msg = msg.encode('utf-8')
|
||||
s.send(msg)
|
||||
bytes = s.recv(1024)
|
||||
print(bytes.decode('utf-8'))
|
||||
s.close()
|
||||
@@ -1,9 +0,0 @@
|
||||
import krypto.hashes
|
||||
|
||||
aufruf_string = 'Hello'
|
||||
aufruf_string = aufruf_string.encode('utf-8')
|
||||
|
||||
print(aufruf_string)
|
||||
aufruf_string = krypto.hashes.hashMod(aufruf_string)
|
||||
|
||||
print(aufruf_string)
|
||||
@@ -1,8 +0,0 @@
|
||||
import krypto.hashes
|
||||
import unittest
|
||||
class TestHash(unittest.TestCase):
|
||||
|
||||
def teste_hashMod(self):
|
||||
first_param = krypto.hashes.hashMod('Hi'.encode('utf-8'))
|
||||
second_param = krypto.hashes.hashMod('Hi'.encode('utf-8'))
|
||||
self.assertEquals(first_param, second_param, 'fehler ungleich')
|
||||
Reference in New Issue
Block a user