C
C
Comeodore2020-08-10 22:09:17
Python
Comeodore, 2020-08-10 22:09:17

How to integrate Python into a website?

I have a WordPress site, what is the easiest way to integrate Python code

import httplib2
import apiclient.discovery
from oauth2client.service_account import ServiceAccountCredentials
FirstName, LastName = input().split(' ')
range='A1:N10000'
CREDENTIALS_FILE = 'creds.json'
spreadsheet_id = '1LlrsWpwBpqBowqgvbNFr7wwZfwGtzqAldQrW668k9bY'
credentials = ServiceAccountCredentials.from_json_keyfile_name(
    CREDENTIALS_FILE,
    ['https://www.googleapis.com/auth/spreadsheets',
     'https://www.googleapis.com/auth/drive'])
httpAuth = credentials.authorize(httplib2.Http())
service = apiclient.discovery.build('sheets', 'v4', http = httpAuth)
values = service.spreadsheets().values().get(
    spreadsheetId=spreadsheet_id,
    range=range,
    majorDimension='ROWS'
).execute()
for i in values['values']:
    if FirstName == i[2] and LastName == i[3]:
        print("Date: " + i[0] + "\nDomain: " + i[1] + "\nFirst Name: " + i[2] + "\nLast Name: " + i[3] + "\nDate of birth: " + i[4] +
              "\nAddress: " + i[5] + "\nApt./Suite: " + i[6] + "\nCity: " + i[7] + "\nZIP: " + i[8] + "\nEmail: " + i[9] + "\nPhone number: " + i[10]
              + "\nSymptoms or conditions: " + i[11] + "\nOther information: " + i[12] + "\nLink on photo: " + i[13])

So, to fill in 2 fields here from the site
owSdsFV.png
And this, to be displayed on the site
nsAzt9i.png
I would be grateful for any information

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
DevMan, 2020-08-10
@Comeodore

the simplest thing is to rewrite the code in php.
and crossing a grass snake with a viper is a so-so idea. though nothing is impossible.

S
SKEPTIC, 2020-08-10
@pro100chel

Django, Flask.
It is possible for python to be a worker, and php to work with it via sockets and transfer tasks.
Web sockets.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question