Advertisement
DrAungWinHtut

flasktest.py

Feb 11th, 2024
880
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.61 KB | None | 0 0
  1. #pip install flask
  2. from flask import Flask
  3.  
  4. app = Flask(__name__)
  5.  
  6. # http://127.0.0.1:5000         /
  7. # http://www.eg.com             /
  8. # http://www.eg.com/info        /info
  9. # http://www.eg.com/admin       /admin
  10. def readFile(fname):
  11.     with open(fname,'r') as file:
  12.         page = file.read()
  13.     return page
  14.  
  15.  
  16.  
  17. @app.route('/')
  18. def homepage():    
  19.     return readFile('home.html')
  20.  
  21.  
  22. @app.route('/info')
  23. def info():
  24.     return readFile('info.html')
  25.  
  26.  
  27. @app.route('/lib')
  28. def lib():
  29.     return readFile('lib.html')
  30.  
  31. if __name__ == '__main__':
  32.     app.run()
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement