Skip to content

Commit

Permalink
Поправки в структуре проекта:
Browse files Browse the repository at this point in the history
Теперь запуск удобнее и проще
  • Loading branch information
Nna2291 committed Mar 2, 2021
1 parent 21e62f2 commit 4e1ac3b
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 15 deletions.
6 changes: 2 additions & 4 deletions home/static/home/js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ var checker = 0
var username = document.getElementById('username').innerHTML
var creater = document.getElementById('create').innerHTML
var room_code = document.getElementById('room_code').innerHTML
console.log(username)
console.log(creater)
if (username == creater) {
var player = 'X';
var times = 'первым';
Expand Down Expand Up @@ -156,8 +154,8 @@ function setAnotherUserText(index , value){


socket.onopen = function (e){
console.log('Сокет соединен')
console.log(JSON.parse(e.data))
console.log('Сокет соединен');
console.log(JSON.parse(e.data));
}

socket.onmessage = function (e){
Expand Down
6 changes: 2 additions & 4 deletions home/templates/home.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
{% load static %}
<html lang="en">
<head>
<link rel="icon" href="{% static 'home/img/favicon.ico' %}" type="image/x-icon">

<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS {% static 'home/css/bootstrap.min.css' %}-->
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0,
maximum-scale=1.0, minimum-scale=1.0">
<link rel="stylesheet" href="{% static 'home/css/style.css' %}">
<link rel="stylesheet"
href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css"
Expand Down
2 changes: 1 addition & 1 deletion home/templates/play.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<!-- Bootstrap CSS -->
<title>Игра | {{room_code}}</title>
<link rel="stylesheet"
Expand Down
6 changes: 4 additions & 2 deletions home/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
from home.game_scoreboard import print_tic_tac_toe
from django.shortcuts import render, redirect
from django.contrib import messages

from launcher.ip_locator import locate
from .models import Game


Expand Down Expand Up @@ -38,12 +40,12 @@ def play(request, room_code):
username = request.GET.get('username')
create = Game.objects.all()
new_create = create.last()
context = {'room_code': room_code, 'username': username, 'create': new_create.game_creator}
context = {'room_code': room_code, 'username': username, 'create': new_create.game_creator,
'ip': locate()}
return render(request, 'play.html', context)


def draw(request):

field = str(request)[35:len(str(request)) - 2].split('&selector_')
for i in range(9):
if len(field[i]) == 3:
Expand Down
12 changes: 8 additions & 4 deletions launch.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
#TODO: добавить в README строку про подключение к интернету
#TODO: проверить работу на raspberry




import os
from launcher.ip_locator import locate
'''os.system('python -m venv venv')
os.system('source venv/bin/activate')
os.system('pip install -r requirements.txt')'''

os.system('python manage.py makemigrations')
os.system('python manage.py migrate')
os.system('clear')
print('______________________________\n\n\n\n\n')
print(f'Адрес для игроков: http://{locate()}:8000\n\n\n')
print('______________________________\n\n\n\n\n\n')
os.system(f'python manage.py runserver {locate()}:8000')
os.system(f'python manage.py runserver 0.0.0.0:8000')

0 comments on commit 4e1ac3b

Please sign in to comment.