main.py 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. #pip install fastapi
  2. #pip install uvicorn
  3. import redis
  4. from fastapi import FastAPI,Form, Request
  5. import json
  6. import uvicorn
  7. import zipfile
  8. import json
  9. from fastapi.middleware.cors import CORSMiddleware
  10. app = FastAPI()
  11. app.add_middleware(
  12. CORSMiddleware,
  13. allow_origins=['*'],
  14. allow_credentials=True,
  15. allow_methods=["*"],
  16. allow_headers=["*"],
  17. )
  18. @app.get("/getbtn")
  19. def read_root(request: Request):
  20. r = redis.Redis(host='db.ptt.cx', port=6379, db=2,password='choozmo9')
  21. data=r.get('btn_data')
  22. return json.loads(data)
  23. @app.get("/liff3")
  24. def liff3(request: Request):
  25. r = redis.Redis(host='db.ptt.cx', port=6379, db=2,password='choozmo9')
  26. data=r.get('liff3')
  27. return json.loads(data)
  28. if __name__ == "__main__":
  29. uvicorn.run("main:app", host="0.0.0.0", port=9898,ssl_keyfile='/etc/letsencrypt/live/liff.googo.org/privkey.pem',ssl_certfile='/etc/letsencrypt/live/liff.googo.org/cert.pem')
  30. #--ssl-keyfile=/etc/letsencrypt/www.choozmo.com/privkey1.pem --ssl-certfile=/etc/letsencrypt/www.choozmo.com/cert1.pem
  31. #/etc/letsencrypt/live/liff.googo.org