
    pjL              	       f   S SK r S SKrS SKrS SKrS SKrS SKrS SKJrJr  S SKJ	r	  S SK
Jr  S SKrS SKJr  S SKJr  S SKJrJrJrJrJrJrJrJrJrJr  SrS	r\" \5      R?                  5       R@                  r!\!S
-  S-  r"\"S-  r#S\SS4S jr$\$" \" S5      5        \" \%5      r&\RN                  " SS5      \&l(        Sr)S\*4S jr+S\RX                  4S jr-\&R\                  S 5       r/SXS\*4S jjr0SXS\*4S jjr1SXS\*4S jjr2S r3\&Ri                  SSS/S9S  5       r5\&Ri                  S!5      S" 5       r6S# r7S$ r8S%\Rr                  S&\*S\*4S' jr:S\Rr                  4S( jr;S%\Rr                  4S) jr<SS*.S%\Rr                  S\*S+\*4S, jjr=S- r>SYS%\Rr                  S.\*S/\*4S0 jjr?S%\Rr                  S1\*4S2 jr@S1\*4S3 jrA\&Ri                  S45      \3S5 5       5       rB\&Ri                  S65      \3S7 5       5       rC\&Ri                  S8SS/S9\3S9 5       5       rD\&Ri                  S:SS/S9\3S; 5       5       rE\&R                  S<5      \3S= 5       5       rG\&Ri                  S>5      \3S? 5       5       rH\&Ri                  S@SS/S9\&Ri                  SASS/S9\&R                  SB5      \3SZSC j5       5       5       5       rI\&Ri                  SD5      \3SE 5       5       rJ\&R                  SF5      \&R                  SG5      \&R                  SH5      \&R                  SI5      \3SZSJ j5       5       5       5       5       rK\&Ri                  SK5      \3SL 5       5       rL\&Ri                  SM5      SN 5       rM\&Ri                  SO5      SP 5       rN\%SQ:X  a:  \&R                  \RN                  " SRSS5      \P" \RN                  " STSU5      5      SVSW9  gg)[    N)datetimetimezonewraps)Path)serialization)padding)
Flaskabortflashgjsonifyredirectrender_templaterequestsessionurl_forzhttps://os.ourvend.com   runtimezvending-webzapp.dbpathreturnc                    U R                  5       (       d  g U R                  5       R                  5        H  nUR                  5       nU(       a  UR	                  S5      (       d  SU;  a  M8  UR                  SS5      u  p4[        R                  R                  UR                  5       UR                  5       5        M     g )N#=   )	exists	read_text
splitlinesstrip
startswithsplitosenviron
setdefault)r   rawlinekeyvalues        5/home/sebas/work/projects/vending-status-pages/app.pyload_env_filer*      s    ;;==~~**,yy{ts++s$ZZQ'



ciik5;;=9 -    z'/home/sebas/runtime/secrets/ourvend.envVENDING_WEB_SECRET_KEYzdev-secret-change-mea)  
create table if not exists products (
  id integer primary key autoincrement,
  product_id text not null unique,
  name text not null,
  price text not null default '0',
  type text not null default '',
  introduction text not null default '',
  image_url text not null default '',
  image_detail_url text not null default '',
  created_at text not null,
  updated_at text not null
);
create table if not exists ads (
  id integer primary key autoincrement,
  ad_key text not null unique,
  title text not null,
  goods_ad_url text not null,
  image_url text not null default '',
  active integer not null default 1,
  created_at text not null,
  updated_at text not null
);
create table if not exists machine_ads (
  machine_id text not null,
  ad_id integer not null,
  primary key (machine_id, ad_id)
);
create table if not exists machine_products (
  machine_id text not null,
  product_id integer not null,
  slot_no text not null default '',
  capacity text not null default '',
  quantity text not null default '',
  primary key (machine_id, product_id)
);
c                  f    [         R                  " [        R                  5      R	                  5       $ N)r   nowr   utc	isoformat r+   r)   now_isor3   O   s    <<%//11r+   c                      S[         ;  ac  [        R                  SSS9  [        R                  " [
        5      n [        R                  U l        U R                  [        5        U [         l
        [         R                  $ )NdbT)parentsexist_ok)r   RUNTIMEmkdirsqlite3connectDB_PATHRowrow_factoryexecutescriptSCHEMAr5   )conns    r)   get_dbrB   S   sQ    1}dT2w'";;6"44Kr+   c                 Z    [         R                  " SS 5      nUb  UR                  5         g g )Nr5   )r   popclose)excr5   s     r)   close_dbrG   ]   s%    	
tT	B	~

 r+   sqlc                 P    [        5       R                  X5      R                  5       $ r.   )rB   executefetchallrH   paramss     r)   	query_allrN   d       8C(1133r+   c                 P    [        5       R                  X5      R                  5       $ r.   )rB   rJ   fetchonerL   s     r)   	query_onerR   h   rO   r+   c                 \    [        5       nUR                  X5      nUR                  5         U$ r.   )rB   rJ   commit)rH   rM   r5   curs       r)   rJ   rJ   l   s%    	B
**S
!CIIKJr+   c                 0   ^  [        T 5      U 4S j5       nU$ )Nc                     > [         R                  " SS5      R                  5       nU(       d  T" U 0 UD6$ [        R                  " S5      (       a  T" U 0 UD6$ [        [        S[        R                  S95      $ )NVENDING_WEB_PASSWORD okloginnext)	r"   getenvr   r   getr   r   r   r   )argskwargspasswordfns      r)   wrapperrequire_login.<locals>.wrappert   se    993R8>>@t&v&&;;tt&v&&gll;<<r+   r   )rc   rd   s   ` r)   require_loginrf   s   s     
2Y= = Nr+   z/loginGETPOST)methodsc            	         [         R                  " SS5      R                  5       n U (       d  [        [	        S5      5      $ [
        R                  S:X  a  [        R                  " [
        R                  R                  SS5      U 5      (       aC  S[        S'   [        [
        R                  R                  S5      =(       d    [	        S5      5      $ [        S	5        [        S
[
        R                  R                  S[	        S5      5      S9$ )NrX   rY   homerh   rb   TrZ   r]   u   Clave inválidaz
login.htmlr\   )r"   r^   r   r   r   r   methodsecretscompare_digestformr_   r   r   r   r`   )rb   s    r)   r[   r[      s    yy/4::<H((~~!!',,"2"2:r"BHMM GDMGLL,,V4GHH <gll.>.>vwv.WXXr+   z/logoutc                  T    [         R                  " 5         [        [        S5      5      $ )Nr[   )r   clearr   r   r2   r+   r)   logoutrr      s    MMOGG$%%r+   c                      [         S-  S-  n U R                  5       (       d  / $ SS KnUR                  U R	                  5       5      nUR                  S/ 5      $ )Nsitezstatus.jsonr   machines)ROOTr   jsonloadsr   r_   )status_pathrw   datas      r)   ru   ru      sO    --/K	::k++-.D88J##r+   c                      [        5        V s/ s H+  o R                  S5      (       d  M  U R                  S5      PM-     sn $ s  sn f )N
machine_id)ru   r_   )ms    r)   machine_idsr~      s1    )1KAuu\7JAEE,KKKs
   AAsession_objrb   c                    U R                  [         S3[        S9R                  R	                  5       nSSR                  [        R                  " US5      5      -   S-   n[        R                  " UR                  5       5      nUR                  UR                  5       [        R                  " 5       5      n[        R                  " U5      R!                  5       $ )Nz/Account/GetPubKeytimeoutz-----BEGIN PUBLIC KEY-----

@   z
-----END PUBLIC KEY-----
)postBASETIMEOUTtextr   jointextwrapwrapr   load_pem_public_keyencodeencryptr	   PKCS1v15base64	b64encodedecode)r   rb   pubpemr'   	encrypteds         r)   encrypt_passwordr      s    


dV#56

H
M
M
S
S
UC
(499X]]35K+L
LOm
mC

+
+CJJL
9CHOO-w/?/?/ABII&--//r+   c                     [         R                  " SS5      R                  5       n [         R                  " SS5      R                  5       nU (       a  U(       d  [        S5      e[        R
                  " 5       nUR                  R                  SS05        [        X!5      nUR                  [         S3XSS	.[        S
9nUR                  R                  S5      (       d  [        SUR                  S S  35      e[         S3SS.nUR                  [         S3[        S9  UR                  [         S3U[        S9  UR                  [         S3U[        S9  UR                  [         S3U[        S9  U$ )NOURVEND_USERNAMErY   OURVEND_PASSWORDz)missing OURVEND_USERNAME/OURVEND_PASSWORDz
User-Agentzvending-web/0.1z/Account/LoginAccount)userAccountuserPwdLoginUrl)rz   r   zok,zpc login failed:    z/OperateMonitor/IndexXMLHttpRequestRefererzX-Requested-Withr   z/OperateMonitor/VerificationPwd)headersr   z#/AssetsManage/GetStringMachineGroupz/OperateMonitor/getSession)r"   r^   r   RuntimeErrorrequestsSessionr   updater   r   r   r   r   r    r_   )usernamerb   suser_pwdrespr   s         r)   vendor_loginr      sS   yy+R0668Hyy+R0668H8FGGAIIl$567,H66&%	R  D
 99&&.tyy#.?@AA!F"78N^_GEETF'
('E:FFdV23WgFVFFdV67RYFZFFdV-.FQHr+   c           	          [          S3SS.nU R                  [          S3USSSSS	.[        S
9nUR                  5       R	                  S/ 5      $ )N/AssetsManage/Indexr   r   z/AssetsManage/ListJson501MIddescrowspagesidxsordr   rz   r   r   )r   r   r   rw   r_   )r   r   r   s      r)   fetch_assets_rowsr      s`    !F"56L\]G&&'CG	  D 99;??62&&r+   )rz   refererc                    [          U 3SS.nU R                  [          U 3XC=(       d    0 [        S9nUR                  5         U$ )Nr   r   r   )r   r   r   raise_for_status)r   r   r   rz   r   r   s         r)   vendor_postr      sK    !F7),BRSGtfTFOW:2W^_DKr+   c                 n   U (       a+  [        U [        5      (       a  U R                  S5      (       d  U $  [        U R	                  S5      R                  S5      R                  S5      S   5      n[        R                  " US-  [        R                  S9R                  5       $ ! [         a    U s $ f = f)Nz/Date(z)/+r   i  )tz)
isinstancestrr    intremoveprefixremovesuffixr!   
ValueErrorr   fromtimestampr   r0   r1   )r%   milliss     r)   parse_vendor_dater      s    jc**#..2J2J
S%%h/<<TBHHMaPQ !!&4-HLLAKKMM  
s   ;B% %B43B4product_typer   c                    [        U SSSSSSS.S9R                  5       R                  S	/ 5      n[        U S
S0 S9R                  5       n[        U SSUSSSUSSSS.S9R                  5       n/ nUR                  S	/ 5       GH<  nUR                  UR                  S5      UR                  S5      =(       d    SUR                  S5      =(       d    SUR                  S5      UR                  S5      UR                  S5      =(       d    SUR                  S5      =(       d    SUR                  S5      =(       d    SUR                  S5      (       a  SUR                  S5       3OS[	        UR                  S5      5      UR                  S5      SSSS.R                  UR                  S5      S5      S S!.5        GM?     XcXES".$ )#Nz/CommodityType/ListJson/CommodityInfo/Index200r   CtIDr   r   r   rz   r   z/CommodityInfo/GetManufacturerz/CommodityInfo/ListJsonPrID0rY   )r   r   r   r   TypePrTypePrCodePrNamer   r   PrRetailPricePrCostPriceCiTypeCiManufacturerPrSpecificationPrImgUrl:https://ourvend-image.oss-cn-qingdao.aliyuncs.com/Regular/
CreateDatePStatuspendingapprovedrejected)r   r      unknownvendor)vendor_product_id
product_idnameprice
cost_pricetypemanufacturerspecification	image_url
created_atstatusstatus_labelsource)products
categoriesmanufacturersr%   )r   rw   r_   appendr   )r   r   r   r   r   payloadr   rows           r)   fetch_vendor_productsr      s   !&S&&I	
 dfSS_   (&	
 df  !&CQ]ilxz  GI  J	
 df  H{{62&!$''(+1rGGH%+WW_-''-0GGH%+GG$45; WW%67=2orovov  xB  pC  pCUVYV]V]^hViUjk  IK+CGGL,ABggi( )jZHLLSWWU^M_ajk
 	 '  !]kkr+   r|   c                 Z   [        U SSUSS.S9R                  5       n[        U SSUSS.S9R                  5       n/ n[        U[        5      (       a  [	        U5      S:  a  US   O/  GH;  nUR                  UR                  S5      =(       d    UUR                  S	5      =(       d    S
UR                  S5      =(       d    S
UR                  S5      =(       d    S
UR                  S5      =(       d    UR                  S5      =(       d    S
UR                  S5      =(       d    S
UR                  S5      =(       d    S
UR                  S5      (       a  SUR                  S5       3OS
UR                  S5      =(       d    S
UR                  S5      =(       d    S
SS.5        GM>     X$US.$ )Nz/Selection/GetCabinetListz/Selection/Indexr   )	MachineIDboxIdr   z/Selection/SoltInfor   SiMachineIdSiCoilIdrY   	SiBarCoder   SiCustomPriceSiPrice
SiCapacitySiExtantQuantityr   r   SiWorkStatusDsiIsDownLoadr   )r|   slot_nor   r   r   capacityquantityr   work_statusdownload_stater   )cabinetsslotsr%   )r   rw   r   listlenr   r_   )r   r|   r	  r%   r
  r   s         r)   fetch_machine_slotsr    s   ;(CM_t~  JM  gN  O  T  T  VH
k#8BTis  B  \C  D  I  I  KCE$S$//CHqLAbH''-0>Jwwz*0b''+.4"GGH%+WW_-I1CIr-3 239rorovov  xB  pC  pCUVYV]V]^hViUjk  IK77>28b!ggo6<"
 	 I !==r+   c                 ^  ^  [        5       n[         S3SS.n[        U5      n[        U 4S jU 5       S 5      nU=(       d    0 R	                  S5      =(       d    SnSST 0S S	4SS
T 0S S4SST 0S S4SS S
T 0S4/n/ nU GH  u  ppUR                  U[         S3X)U
[        S9nUUUR                  UR                  R	                  S5      UR                  S S SS US S.	n UR                  5       US'   US   R	                  S5      nUS   R	                  S5      nUS:H  US'   US:X  a  US	:X  az  [        S5       Hk  n[        U5      n[        U 4S jU 5       S 5      nU=(       d    0 R	                  S5      =(       d    SnU(       a  UUS'     O[        R                  " S5        Mm     US:X  a  S US!'   O=US":X  a  S#US!'   O1US:X  a  US   (       a  S$US!'   OUS:X  a  S%US!'   OU(       a  S&U 3US!'   UR                  U5        GM     U$ ! [         a    UR                  S':X  a  S(US!'    N9f = f))Nr   r   r   c              3   T   >#    U  H  oR                  S 5      T:X  d  M  Uv   M     g7fr   Nr_   .0rr|   s     r)   	<genexpr>#fetch_screenshot.<locals>.<genexpr>  s      L+Qu1Kqq+   (	(UrlrY   rh   midzUI-real payloadr   zlegacy guess: MachineIDr   zlegacy guess: MIdrg   zlegacy GET guessz/AssetsManage/Screenshot)r   rz   rM   r   zcontent-typei  F)	labelrl   status_codecontent_typebodyrZ   summary
before_url	after_urlrw   msgcoder   rZ      c              3   T   >#    U  H  oR                  S 5      T:X  d  M  Uv   M     g7fr  r  r  s     r)   r  r  8  s      N4a55<:3M4r  r      u   机器离线u4   Vendor respondió: máquina offline para screenshot.r  u   机器号不能为空uH   Vendor respondió: faltó el nombre correcto del parámetro de máquina.uC   Vendor aceptó la orden y devolvió URL de screenshot en la grilla.uH   Vendor aceptó la orden, pero la URL todavía no apareció en la grilla.u   Vendor respondió: i  u1   Vendor devolvió 403. Ese shape no tiene permiso.)r   r   r   r]   r_   r   r   r  r   r   rw   rangetimesleep	Exceptionr   )r|   r   r   before_rows
before_rowr  attemptsoutrl   rz   rM   r  r   itemr!  r"  _r   r   urls   `                   r)   fetch_screenshotr1    ss   A!F"56L\]G#A&KL+LdSJ"''.4"J	%$d,=>	+z*D2KL	%$d,?@	{J/1CD	H C'/#fyyD6)A!BGgmw~y++ LL,,^<IIet$$

	V99;DLv,""5)C<##F+DDJqyU&77qA,Q/DN4NPTUC9"//%06BC,/[)JJqM " n$"XY//"lYtK0"gY"lY$7u"=Y 	

4Q (0R J	  	V3&"UY	Vs+    CH
5H
H
H
#H

H,+H,/c                      S n SnS n [        [        5       5      n[        US   5      n [        SX[        5       US9$ ! [         a  n[	        U5      n S nAN.S nAff = f)Nr   r   z	home.html)r   adsru   vendor_error)r   r   r  r)  r   r   ru   )products_count	ads_countr5  r   rF   s        r)   rk   rk   O  sf     NIL &|~6VJ/0 ;YaYcr~   3x s   != 
AAAz	/productsc                      S n / n/ n [        [        5       5      nUS   nUS   n[	        SXU S9$ ! [         a  n[        U5      n  S nAN%S nAff = f)Nr   r   zproducts.html)r   r   error)r   r   r)  r   r   )r9  r   r   r   rF   s        r)   products_indexr:  ]  se     EHJ'7:&\*
 ?X\abb  Cs   0 
AA

Az/products/newc                  F   S n 0 SS_SS_SS_SS_SS_SS_SS_S	S_S
S_SS_SS_SS_SS_SS_SS_SS_n [        5       n[        U5      n[        R                  S:X  a{  UR	                  U Vs0 s H#  oD[        R
                  R                  US5      _M%     sn5        [        USSUS9n[        SUR                  S S  35        [        [        S5      5      $ [        SSSUS   US   XS9$ s  snf ! [         a#  n[        U5      n [        SSS/ / XS9s S nA$ S nAff = f) NProductNamerY   ProductCoder   r   r   Manufacturersr   	PrContentPrAdultLimitr   PrAliAdultLimitPrPromotionPricePrMemberPrice
PrDiscount	PrTaxRateQualityPeriodImgPathrh   z/CommodityInfo/AddCIr   r   zProducto enviado a OurVend: x   r:  product_form.htmlzNuevo productoz)Alta real en OurVend /CommodityInfo/AddCIr   r   titlesubtitler   r   ro   r9  )r   r   r   rl   r   ro   r_   r   r   r   r   r   r   r)  r   )r9  r   r   metakr   rF   s          r)   products_newrO  l  sL    E I}b  I-  I_b  I-Y[  I]egi  Ikz|~  I  AR  TV  I  Xc  eg  I  iw  y|  I  ~O  QT  I  Vh  jl  I  n}  A  I  CO  QS  I  U`  bd  I  fu  wy  I  {D  FH  IG~$V,>>V#NNH1w||//266HIv'=G]dklD04C0ABCG$45662:J  VA  NR  S_  N`  pt  uD  pE  LS  a  	a	 I
  ~C2:J  VA  NP  `b  ip  ~  	~~s6   8C3 .*C.AC3 C3 .C3 3
D =DD D z"/products/<vendor_product_id>/editc                 6  ^  S n0 ST _SS_SS_SS_SS_SS_SS_S	S_S
S_SS_SS_SS_SS_SS_SS_SS_SS_n [        5       n[        U5      n[        U 4S jUS    5       S 5      nU(       aN  UR                  US   US   US   =(       d    SUS   =(       d    SUS   =(       d    SUS   =(       d    SS.5        [        R
                  S:X  a{  UR                  U Vs0 s H#  of[        R                  R                  US5      _M%     sn5        [        USSUS 9n[        S!UR                  S S"  35        [        [        S#5      5      $ [        S$S%T  3S&US'   US(   X!S)9$ s  snf ! [         a&  n[        U5      n[        S$S%T  3S&/ / X!S)9s S nA$ S nAff = f)*Nr   r<  rY   r=  r   r   r   r>  r   r?  r@  r   rA  rB  rC  rD  rE  rF  rG  c              3   b   >#    U  H$  n[        US    5      [        T5      :X  d  M   Uv   M&     g7f)r   N)r   )r  pr   s     r)   r   products_edit.<locals>.<genexpr>  s.     m#3as1=P;Q7RVYZkVl7l#3s   /	/r   r   r   r   r   r   r   )r<  r=  r   r   r   r   rh   z/CommodityInfo/EditCIr   r   z!Producto actualizado en OurVend: rH  r:  rI  zEditar producto u.   Edición real en OurVend /CommodityInfo/EditCIr   r   rJ  )r   r   r]   r   r   rl   ro   r_   r   r   r   r   r   r   r)  r   )	r   r9  ro   r   rM  currentrN  r   rF   s	   `        r)   products_editrU    s8    E aF%  a}b  a-  a_^`  aboqs  au}  @B  a  DS  UW  a  Yj  ln  a  p{  }  a  AO  QT  a  Vg  il  a  n@  BD  a  FU  WY  a  [g  ik  a  mx  z|  a  ~M  OQ  a  S\  ^`  aDV$V,m4
#3mostKKP\H]pwx  qA  qG  EG  X_  `l  Xm  Xs  qs  F  GM  N  T  RT  ip  q@  iA  iG  EG  H  I>>V#KKTBTGLL,,Q33TBCv'>H^eijD5diio5FGHG$45662<LM^L_:`  l\  im  nz  i{  KO  P_  K`  gk  y  	y	 C
  VC2<LM^L_:`  l\  ik  {}  DH  V  	VVs7   B&E(  *E#
AE( E( #E( (
F2FFFz$/products/<vendor_product_id>/deletec                     [        5       n[        USSSU 0S9n[        SUR                  S S  35        [	        [        S5      5      $ )Nz/CommodityInfo/Deleter   r   r   zProducto borrado en OurVend: rH  r:  )r   r   r   r   r   r   )r   r   r   s      r)   products_deleterW    sP     ^Fv6@V^dfw]xyD	)$))DS/):
;<G,-..r+   z/adsc                      [        S/ S SS9$ )Nzads.htmluG   Ads reales todavía en recon. La app ya no usa sqlite fake como verdad.)r4  r9  unsupported_reason)r   r2   r+   r)   	ads_indexrZ    s      :2T  OX  Y  Yr+   z/ads/newz/ads/<path:_unsupported>/editz/ads/<path:_unsupported>/deletec                 @    [        S5        [        [        S5      5      $ )NzEAds write path bloqueado hasta confirmar endpoints reales de OurVend.rZ  r   r   r   )_unsupporteds    r)   ads_write_blockedr^    s    
 

QRGK())r+   z	/machinesc            
          / n S n [        5       n[        5        H&  nU R                  0 UES[        X#S   5      0E5        M(     [        SXS9$ ! [         a  n[        U5      n[        5       n  S nAN.S nAff = f)Nvendor_slotsr|   zmachines.html)ru   r9  )r   ru   r   r  r)  r   r   )machine_viewsr9  r   machinerF   s        r)   machines_indexrc    s     ME#NzG  !kG!k^=PQR\hTi=j!kl "
 ?]PP  #C 
#s   >A 
A7A22A7z/machines/<machine_id>/productsz:/machines/<machine_id>/products/<path:_unsupported>/deletez/machines/<machine_id>/adsz5/machines/<machine_id>/ads/<path:_unsupported>/deletec                 H    [        SU  S35        [        [        S5      5      $ )NzMachine link write path for z, bloqueado hasta migrar write endpoint real.rc  r\  )r|   r]  s     r)   machine_link_write_blockedre    s(     
(4`
abG,-..r+   z/screenshots/<machine_id>c                     S nS n[         R                  R                  S5      S:X  a   [        U 5      n[        SXU[        5       S9$ ! [         a  n[        U5      n S nAN.S nAff = f)Nrunr   zscreenshot.html)r|   resultr9  ru   )r   r`   r_   r1  r)  r   r   ru   )r|   rh  r9  rF   s       r)   screenshotsri    sh     FE||#%	%j1F ,Z_jrjtuu  	HE	s   A 
A'A""A'z/api/machines/<machine_id>/feedc           
           [        [        5       U 5      nUS   n[        SU [	        5       U/ SSS.5      $ ! [         a-  n[        SU [	        5       [        U5      S.5      S4s S nA$ S nAff = f)	NF)rZ   r|   generated_atr9  i  r
  Tblocked_unconfirmedr   )rZ   r|   rk  r   r4  
ads_statusr   )r  r   r)  r   r3   r   )r|   slots_payloadrF   r
  s       r)   api_machine_feedro    s    s+LNJG '"E 	+    se:wycfgjcklmorrrss   6 
A- "A("A-(A-z/api/healthc                  8    [        S[        [        5      S.5      $ )NT)rZ   r5   )r   r   r<   r2   r+   r)   healthrq    s    $c'l344r+   __main__HOSTz	127.0.0.1PORT5081T)hostportdebug)r2   )r   r   r.   )Qr   r"   rm   r:   r   r'  r   r   	functoolsr   pathlibr   r   cryptography.hazmat.primitivesr   )cryptography.hazmat.primitives.asymmetricr	   flaskr
   r   r   r   r   r   r   r   r   r   r   r   __file__resolveparentrv   r8   r<   r*   __name__appr^   
secret_keyr@   r   r3   
ConnectionrB   teardown_appcontextrG   rN   rR   rJ   rf   router[   rr   ru   r~   r   r   r   r   r   r   r   r  r1  rk   r:  rO  rU  r   rW  rZ  r^  rc  re  ri  ro  rq  rg  r   r2   r+   r)   <module>r     s    	     '    8 = g g g
H~&&

]
*
H
: : : d<= >Ho35KL$
N2 2""   43 443 4 	 8eV_-	Y .	Y 9& &
$L0("2"2 0c 0c 0h&& .'8#3#3 ' QU X-- S c N$lx'7'7 $ls $lX[ $lN>X%5%5 >3 >*6 6r 3	@  	@ ;
c  
c ?UFO4~  5~" /%IV  JV( 
01/  2/ 6Y  Y :v/*UFOD
+,*  - E 0*
 ;
Q  
Q 
+,
FG
&'
AB/  C ( H -
/
 &'v  (v ,- ." =5 5 zGG6;/c"))FF:S6T\`Ga r+   