@martoy

Js код не выводит не чего, а если и выводит то какуе-то ерись, программа с веб интерфейсом, как исправить?

Python код!
import eel
import random
import string
import webbrowser
import time
import requests
from termcolor import colored, cprint
import colorama
import os
import platform
import threading
from fake_useragent import UserAgent
from sys import argv, exit
from threading import Thread

@eel.expose
def free(place):
	y = ''.join(random.choice(string.ascii_uppercase + string.digits + string.ascii_lowercase) for _ in range(15))
	return y

eel.init("C:/Users/Martoy/Desktop/privat/web")

eel.start("reg.html",size=(600,550))

html
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>Discord Nitro SignUp</title>

	<script src="eel.js"></script>
	<link rel="icon" type="image/png" href="/favicon.png">
	<link rel="stylesheet" href="main.css">
	<link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css2?family=Montserrat:wght@300&display=swap" rel="stylesheet">
</head>
<body>

	<h1>Испытай удачу! Получи код бесплатно!</h1>
	<input id="location" type="text" placeholder="Здесь будет код" required="">
	<button id="show2">Испытать удачу</button>
	<div id="info"></div>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
  <script type="text/javascript">
    
    async function display_weather(){
      let res=await eel.free(place);
      document.getElementById('location').innerHTML=res;
    }
    jQuery('#show2').on('click', function(){display_weather();});
	</script>

</body>
</html>
  • Вопрос задан
  • 127 просмотров
Пригласить эксперта
Ответы на вопрос 1
SoreMix
@SoreMix Куратор тега Python
yellow
1. innerHTML в данном случае не нужен. Если нужен просто текст в input - за него отвечает параметр value
2. В консоли четко написано, что place в строке let res=await eel.free(place) не определена.
3. Функция не вызвана в конечном итоге

Рабочий вариант:

<script type="text/javascript">
    async function display_weather(){
      let res=await eel.free('place?')();
      document.getElementById('location').value=res;
    }
    jQuery('#show2').on('click', function(){display_weather();});
  </script>
Ответ написан
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы