main.py 897 B

1234567891011121314151617181920212223242526272829
  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. from fastapi.middleware.cors import CORSMiddleware
  9. app = FastAPI()
  10. app.add_middleware(
  11. CORSMiddleware,
  12. allow_origins=['*'],
  13. allow_credentials=True,
  14. allow_methods=["*"],
  15. allow_headers=["*"],
  16. )
  17. @app.get("/getbtn")
  18. def read_root(request: Request):
  19. r = redis.Redis(host='db.ptt.cx', port=6379, db=2,password='choozmo9')
  20. data=r.get('btn_data')
  21. return {'data':data}
  22. if __name__ == "__main__":
  23. 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')
  24. #--ssl-keyfile=/etc/letsencrypt/www.choozmo.com/privkey1.pem --ssl-certfile=/etc/letsencrypt/www.choozmo.com/cert1.pem
  25. #/etc/letsencrypt/live/liff.googo.org