jeudi 4 juillet 2019

How to capture inputs in html and send to python

Im trying to set a web page that only shows inputs that collect: A EXCEL PATH SHEET RANGE and then a python script uses the variables to open the excel and take a screenshot of the Sheet:Area i have already the python script but to transfer from cmd to web i dont have any idea

Im already try django and flask both i dont understand their use

This is my html

<form name = "search" action="." method="POST">
    <label>Ruta:</label>
    <input type="text" name="path">
    <label>Hoja:</label>
    <input type="text" name="sheet">
    <label>Rango:</label>
    <input type="text" name="range">
    <p></p>
    <label>Ruta de Guardado:</label>
    <input type="text" name="path2">
    <label>Alto:</label>
    <input type="number" name="height">
    <label>Ancho:</label>
    <input type="number" name="wid">
    <p></p>
</form>

In the app.py (flask) project

app.route('/', methods=['POST'])
def getValue():
    path = request.form['path']
    sheet = request.form['sheet']
    range = request.form['range']
    path2 = request.form['path2']
    he = request.form['height']
    wd = request.form['wid']
    excel2img.export_img(path,"test8.png", sheet, range)

My python script (works with cmd)

enter code here
import excel2img
from PIL import Image
import os

path = input('Introduce la ruta del archivo: ')     
sheet = input("Introduce el nombre del hoja: ") 
range = input("Introduce el rango: ") 
save = input("Introduce ruta de guardado")
he = int(input("Introduce alto de la imagen: "))
wd = int(input("Introduce el ancho de la imagen: "))

path = archivo.replace("\\", "/") 
num = 7


excel2img.export_img(path, save + r"\test"+str(num) + ".png", sheet, range) 

print(save + "test7.png")
im =Image.open(save + r"\test7.png")
im = im.resize((wd, he)) 
im.save(save+r"\test7.jpg")




Aucun commentaire:

Enregistrer un commentaire