jeudi 1 avril 2021

Is Google input tool available to use in website input translation or not?

i'm trying to use this: https://developers.google.com/transliterate/v1/getting_started , when i'm use this it shows following error: Loading "elements" other than "inputtools" is unsupported. and in its top gives following message:

The Google Transliterate API has been officially deprecated as of May 26, 2011. It will continue to work as per our deprecation policy.

any one help me how can i use this?




ListView with Firebase data

since I decided to create a list of my Firestore-data my project became a whole horror trip. What I'm trying to do is following:

I want to import the data from my firestore database and include it into my list view. The following extract of my code throws no error but instead it shows the message when structs is empty. So my only idea is that the import of the firebase data or something to add this to my ListView didn't worked.

As I said that only an extract of my code but I think the error has to be somewhere inside here:

class __HomeStateState extends State<_HomeState> {
  final firestoreInstance = FirebaseFirestore.instance;

  @override
  Widget build(BuildContext context) {
    final provider = Provider.of<StructureProvider>(context);
    final structs = provider.structs;
    return structs.isEmpty
        ? Center(
            child: Text("Keine Einträge vorhanden"),
          )
        : Scaffold(
            body: StreamBuilder<List<Structure>>(
                stream: FirebaseApi.readStructs(),
                builder: (context, snapshot) {
                  final structs = snapshot.data;
                  final provider = Provider.of<StructureProvider>(context);
                  provider.setStructs(structs);

                  return ListView.separated(
                      padding: EdgeInsets.all(20),
                      physics: BouncingScrollPhysics(),
                      separatorBuilder: (context, index) => Container(
                            height: 10,
                          ),
                      itemCount: structs.length,
                      itemBuilder: (context, index) {
                        final struct = structs[index];
                        return StructureWidget(struct: struct);
                      });
                }));
  }
}

class Structure {
  DateTime createdTime;
  String vorname;
  String nachname;
  String geburtstag;
  String adresse;
  String telefon;
  int id;
  bool isDone;

  Structure(
      {@required this.createdTime,
      @required this.nachname,
      this.vorname = "",
      this.geburtstag = "",
      this.adresse = "",
      this.telefon = "",
      this.id,
      this.isDone});

  static Structure fromJson(Map<String, dynamic> json) => Structure(
        createdTime: Utils.toDateTime(json['createdTime']),
        vorname: json['vorname'],
        nachname: json['nachname'],
        geburtstag: json['geburtstag'],
        adresse: json['adresse'],
        telefon: json['telefon'],
        id: json['id'],
        isDone: json['isDone'],
      );
}


class StructureProvider extends ChangeNotifier {
  List<Structure> _struct = [];

  List<Structure> get structs => _struct.toList();

  void setStructs(List<Structure> structs) =>
      WidgetsBinding.instance.addPostFrameCallback((_) {
        _struct = structs;
        notifyListeners();
      });
}

class FirebaseApi {
  static Stream<List<Structure>> readStructs() => FirebaseFirestore.instance
      .collection("users")
      .snapshots()
      .transform(Utils.transformer(Structure.fromJson));
}

Thanks for any kind of help :)




BeautifulSoup findAll error when searching for a href tags

In this code I am scraping a website for all "a" tags inside all "div class='image'" found on the page and print out the contents of each "a" tag inside all the "image" classes on the page.

from bs4 import BeautifulSoup
import os

#edible mushroom scraping
url = 'http://www.mushroom.world/mushrooms/edible?page=0'
r = requests.get(url)
soup = BeautifulSoup(r.text, 'html.parser')


#find all image classes
images = soup.find('div', attrs={'class': 'image'})

#images = soup.select('div.class image')

#find all images within class
for link in images.findAll("a"):
    #get url ending from image a href
    image_url= (link.get('href'))
    #creates usable url
    image_url = image_url.replace('/../', 'https://www.mushroom.world/')
    print(image_url)

I believe the issue with the code is around the:

#find all image classes
images = soup.find('div', attrs={'class': 'image'})

when using soup.find, images is set to the first div of class images, and the rest of the code successfully retrieves the internal "a" tag found inside the first "image" class, however, when I set the code to:

#find all image classes
images = soup.find_all('div', attrs={'class': 'image'})

in order to go through all "image" class divs, then the code gives the error:

Exception has occurred: AttributeError
ResultSet object has no attribute 'findAll'. You're probably treating a list of elements like a single element. Did you call find_all() when you meant to call find()?



Offline interactive web page on Windows Chrome

I hope my question is good enough for this forum.

Background

I have an Imaging system that includes: Several types of cameras Arduino motors with CNC controllers.

I have a python app that controls those modules and generates for me the desired image of my scan. Most of the time I have a default configuration for my scan plan, and sometimes I need to change it. The parameters of configurations are implemented within the code itself, very cumbersome.

My goal

I want to create A GUI for this app, In order to make it the easiest to use for the standard user. ( Which is not familiar at all with python and coding). I thought of an offline web-page app (No internet required at all). For example, my idea is as shown in the picture: enter image description here

My Questions

  1. I thought about implementing this with python (Flask/Django) with I'm not that much familiar with, as mentioned in comments here: Publishing interactive scientific results in Python what functions/ libraries will be relevant for my goal?

  2. How do I create an accessing ( Save and Open) computer's files via an Offline web?

  3. I've tried to find an example that is close and relevant for me, but I haven't found it yet. If someone has anything that might seem relevant to me I would be more than happy to hear about it.

Thank you very much!




AttributeError: module 'djangoschool' has no attribute 'wsgi'

I once finished deploy it on another server without this error, but I try this with new server and install my new window server 2019.I start do it again but it got an error.

I deploy my django project on IIS.I follow this tutorial https://www.youtube.com/watch?v=CpFU16KrJcQ When I browse my website on localhost. It got error messages like this.

Error occurred while reading WSGI handler:

Traceback (most recent call last):
  File "c:\python37\lib\site-packages\wfastcgi.py", line 791, in main
    env, handler = read_wsgi_handler(response.physical_path)
  File "c:\python37\lib\site-packages\wfastcgi.py", line 633, in read_wsgi_handler
    handler = get_wsgi_handler(os.getenv("WSGI_HANDLER"))
  File "c:\python37\lib\site-packages\wfastcgi.py", line 603, in get_wsgi_handler
    handler = getattr(handler, name)
AttributeError: module 'djangoschool' has no attribute 'wsgi'


StdOut: 

StdErr: 

Location: C:\intepub2\wwwroot

web.config

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.webServer>
    <handlers>
      <add name="Python FastCGI" 
      path="*" 
      verb="*" 
      modules="FastCgiModule" 
      scriptProcessor="c:\python37\python.exe|c:\python37\lib\site-packages\wfastcgi.py"
      resourceType="Unspecified" 
      requireAccess="Script" />
    </handlers>
  </system.webServer>

  <appSettings>
    <add key="PYTHONPATH" value="C:\inetpub2\wwwroot\djangoschool" />
    <add key="WSGI_HANDLER" value="djangoschool.wsgi.application" />
    <add key="DJANGO_SETTINGS_MODULE" value="djangoschool.settings" />
  </appSettings>
</configuration>

Location: C:\intepub2\wwwroot\djangoschool\djangoschool

settings.py

"""
Django settings for djangoschool project.

Generated by 'django-admin startproject' using Django 3.1.4.

For more information on this file, see
https://docs.djangoproject.com/en/3.1/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/3.1/ref/settings/
"""

from pathlib import Path
import os
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'y!6o7s+hwc=5_n(((=be3#ktnqycq@2^0bez!$6!p8baep_^o7'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = ['localhost']


# Application definition

INSTALLED_APPS = [
    'school',
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'import_export'
]

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 = 'djangoschool.urls'

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [os.path.join(BASE_DIR,'school/template')],
        #'DIRS': [BASE_DIR,'school/template'],
        '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 = 'djangoschool.wsgi.application'


# Database
# https://docs.djangoproject.com/en/3.1/ref/settings/#databases

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        #'NAME': BASE_DIR / 'db.sqlite3',
        'NAME': os.path.join(BASE_DIR,'db.sqlite3'),
    }
}


# Password validation
# https://docs.djangoproject.com/en/3.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/3.1/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.1/howto/static-files/
IMPORT_EXPORT_USE_TRANSACTIONS = True

STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')


LOGIN_URL = 'login'
LOGOUT_REDIRECT_URL = 'login'
LOGIN_REDIRECT_URL = 'home-page'

Location: C:\intepub2\wwwroot\djangoschool\djangoschool

wsgi.py

"""
WSGI config for djangoschool 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/3.1/howto/deployment/wsgi/
"""

import os

from django.core.wsgi import get_wsgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'djangoschool.settings')

application = get_wsgi_application()




getting query parameter on initial route flutter

I'm working on a flutter application mainly for the web, and I'm unable to add/get the query parameter from the URL, the query parameter will contain an id, and this id should be used inside the app

this my route setup on my app state:

  return MaterialApp(navigatorKey: key,  initialRoute: '/main',
        routes: {
          // When navigating to the "/" route, build the FirstScreen widget.
          '/main': (context) => Map_View(),
          // When navigating to the "/second" route, build the SecondScreen widget.
          '/second': (context) => TaskClosed(),
        },onGenerateRoute: RouteGenerator.generateRoute,);
  }


  class RouteGenerator{
    
      static Route<dynamic> generateRoute(RouteSettings settings){
        final args = settings.arguments;
        print(args);
        var routingData = settings.name;
      }}

the settings.arguments are always null

so what should I pass to initialRoute to make it accept arguments on the first screen for example, the calling URL should be like this:

https:example.com/main?123

so how to get this parameter from the URL




Do I need a Linux machine for back-end web development in PHP?

That is the question: do I need a Linux machine for back-end web development in PHP?

I do not understand fully how might the operating system have anything to do with something deployed on the web if you are not hosting the site locally.

Also, if I do not have a Linux machine, can I replace it by running WSL on my Windows PC? Or are there some fatal drawbacks that might point to not doing that?

Thanks