o
    uh                     @   sX   d dl mZmZmZ d dlZeeZejddgddd Zejdd	gdd
d Z	dS )    )Flaskrender_template_stringrequestN/GET)methodsc                   C   s   t dS )Nz
        <h2>Upload Amazon Orders to Cin7</h2>
        <form method="post" action="/run">
            <button type="submit">Run Script</button>
        </form>
    )r    r   r   /var/www/Python/app.pyindex   s   r
   z/runPOSTc               
   C   sx   zt jddgt jt jdddd} d| j dW S  t jy"   Y d	S  ty; } zd
t| dW  Y d }~S d }~ww )Npython3z'/var/www/Python/Finialwitherroremail.pyx   zutf-8replace)stdoutstderrtimeoutencodingerrorsu   <h3>✅ Output:</h3><pre>z</pre>u   <h3>❌ Script timed out.</h3>u   <h3>❌ Error:</h3><pre>)
subprocessrunPIPESTDOUTr   TimeoutExpired	Exceptionstr)resulter   r   r	   
run_script*   s    r   )
flaskr   r   r   r   __name__approuter
   r   r   r   r   r	   <module>   s    
#