Advertisement
Guest User

Untitled

a guest
Jun 10th, 2025
28
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 7.03 KB | None | 0 0
  1. # used in production config
  2. # REMEMBER_COOKIE_SECURE = True
  3. import os
  4. import stripe  
  5. from datetime import timedelta
  6.  
  7. # used in production config
  8. # REMEMBER_COOKIE_SECURE = True
  9. import os
  10. import stripe  
  11. from datetime import timedelta
  12.  
  13.  
  14.  
  15.  
  16.  
  17.  
  18. '''I need to fix base_directory '''
  19. # This gives the path the current folder of my directory in. This is an absolute import.
  20. # example below
  21. base_directory = os.path.abspath(os.path.dirname(__file__))
  22.  
  23. Pytest_db_uri = os.environ.get('TEST_DATABASE_URI') or \
  24.     'sqlite:///' + os.path.join(base_directory, 'test_app.db')
  25.  
  26.  
  27.  
  28.  
  29. basedir = os.path.abspath(os.path.dirname(__file__))
  30.  
  31. class Config:        
  32.     # what does sqlite/// do ?
  33.     # what is object ?
  34.     SQLALCHEMY_DATABASE_URI = os.environ.get('DATABASE_URI') or \
  35.         'sqlite:///' + os.path.join(basedir, 'app.db')
  36.  
  37.  
  38.  
  39.  
  40.     # Setup CSRF secret key
  41.     # change to environment variable todo!
  42.     SECRET_KEY = 'temp_secret_key'
  43.     SQLALCHEMY_TRACK_MODIFICATIONS = False
  44.     # setting up Outlook email for flask mail
  45.     MAIL_SERVER='smtp.googlemail.com'
  46.     MAIL_PORT=587
  47.     MAIL_USE_TLS=1
  48.     # The max file size is now 16 megabytes.
  49.     MAX_CONTENT_LENGTH = 16 * 1000 * 1000
  50.     # logs you in for 6 min after closing the browser
  51.     REMEMBER_COOKIE_DURATION = timedelta(seconds=360)
  52.  
  53.     SQLALCHEMY_DATABASE_URI =  'sqlite:///' + os.path.join(basedir, 'app.db')
  54.     ''' Database For pytest'''
  55.     # for 2+ databases to make the second db work
  56.     SQLALCHEMY_BINDS = { "testing_app_db": Pytest_db_uri }  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64. from pathlib import Path
  65.  
  66. class DevelopmentConfig(Config):    
  67.     # should it be False? NO.
  68.     DEBUG = True
  69.     # for pytest if True it blocks emails in flask mail from being sent
  70.     TESTING = False    
  71.     # This will be the same value as 'DEBUG = ...'
  72.     Mail_DEBUG = True  
  73.     # This is the default email that you get when you send an email?
  74.     MAIL_DEFAULT_SENDER = None  
  75.     # You can only send x amount of emails at one time. Can also be set to None.
  76.     MAIL_MAX_EMAILS = 5  
  77.     # same value 'TESTING = ...'. If you are testing your app if you don't want to send emails make it True?
  78.     # ['MAIL_SUPRESS_SEND'] = False
  79.     # converts the file name to ascii. ascii characters are english characters. (Why use this?)
  80.     MAIL_ASCII_ATTACHMENTS = False
  81.     # Used to save to the uploaded folder
  82.     # UPLOAD_FOLDER = r"C:\Users\user\OneDrive\Desktop\flaskcodeusethis\flaskblog2\app\static\profilepictures"
  83.     #UPLOAD_FOLDER = os.path.abspath(base_directory + r"\app\static\profilepictures")
  84.     UPLOAD_FOLDER = Path.cwd().joinpath("app", "static", "profilepictures")
  85.     # max a file can be is 1 megabyte is that big enough? Todo add warning
  86.     MAX_CONTENT_LENGTH = 1024 * 1024
  87.     CKEDITOR_PKG_TYPE = 'standard'
  88.     # setting up flask mail
  89.     MAIL_USERNAME = os.getenv("EMAIL_USERNAME")
  90.     # app password
  91.     MAIL_PASSWORD = os.getenv("EMAIL_PASSWORD")
  92.     # make secret key work in wtf forms
  93.     WTF_CSRF_ENABLED = True
  94.     # this is the test key for stripe
  95.     stripe.api_key = os.environ['STRIPE_SECRET_KEY']
  96.  
  97.  
  98. class PytestConfig(Config):
  99.     DEBUG = False
  100.     EMAIL_HOST = 'localhost'
  101.     EMAIL_PORT = '0'
  102.     Mail_DEBUG = True  
  103.     # for pytest
  104.     TESTING = True     
  105.     # This is the same value ['TESTING'] =...
  106.     # If you are testing your app and you don't want to send emails make the value True?
  107.     MAIL_SUPRESS_SEND = True  
  108.     # When this is False wtf_forms is disabled. This makes 'POST' request work for pytest routes.
  109.     WTF_CSRF_ENABLED = False
  110.     SQLALCHEMY_TRACK_MODIFICATIONS = True
  111.     SERVER_NAME = 'localhost'
  112.  
  113.  
  114.  
  115.  
  116. '''I need to fix base_directory '''
  117. # This gives the path the current folder of my directory in. This is an absolute import.
  118. # example below
  119. base_directory = os.path.abspath(os.path.dirname(__file__))
  120.  
  121. Pytest_db_uri = os.environ.get('TEST_DATABASE_URI') or \
  122.     'sqlite:///' + os.path.join(base_directory, 'test_app.db')
  123.  
  124.  
  125.  
  126.  
  127. basedir = os.path.abspath(os.path.dirname(__file__))
  128.  
  129. class Config:        
  130.     # what does sqlite/// do ?
  131.     # what is object ?
  132.     SQLALCHEMY_DATABASE_URI = os.environ.get('DATABASE_URI') or \
  133.         'sqlite:///' + os.path.join(basedir, 'app.db')
  134.  
  135.  
  136.  
  137.  
  138.     # Setup CSRF secret key
  139.     # change to environment variable todo!
  140.     SECRET_KEY = 'temp_secret_key'
  141.     SQLALCHEMY_TRACK_MODIFICATIONS = False
  142.     # setting up Outlook email for flask mail
  143.     MAIL_SERVER='smtp.googlemail.com'
  144.     MAIL_PORT=587
  145.     MAIL_USE_TLS=1
  146.     # The max file size is now 16 megabytes.
  147.     MAX_CONTENT_LENGTH = 16 * 1000 * 1000
  148.     # logs you in for 6 min after closing the browser
  149.     REMEMBER_COOKIE_DURATION = timedelta(seconds=360)
  150.  
  151.     SQLALCHEMY_DATABASE_URI =  'sqlite:///' + os.path.join(basedir, 'app.db')
  152.     ''' Database For pytest'''
  153.     # for 2+ databases to make the second db work
  154.     SQLALCHEMY_BINDS = { "testing_app_db": Pytest_db_uri }  
  155.  
  156.  
  157.  
  158.  
  159.  
  160.  
  161.  
  162. from pathlib import Path
  163.  
  164. class DevelopmentConfig(Config):    
  165.     # should it be False? NO.
  166.     DEBUG = True
  167.     # for pytest if True it blocks emails in flask mail from being sent
  168.     TESTING = False    
  169.     # This will be the same value as 'DEBUG = ...'
  170.     Mail_DEBUG = True  
  171.     # This is the default email that you get when you send an email?
  172.     MAIL_DEFAULT_SENDER = None  
  173.     # You can only send x amount of emails at one time. Can also be set to None.
  174.     MAIL_MAX_EMAILS = 5  
  175.     # same value 'TESTING = ...'. If you are testing your app if you don't want to send emails make it True?
  176.     # ['MAIL_SUPRESS_SEND'] = False
  177.     # converts the file name to ascii. ascii characters are english characters. (Why use this?)
  178.     MAIL_ASCII_ATTACHMENTS = False
  179.     # Used to save to the uploaded folder
  180.     # UPLOAD_FOLDER = r"C:\Users\user\OneDrive\Desktop\flaskcodeusethis\flaskblog2\app\static\profilepictures"
  181.     #UPLOAD_FOLDER = os.path.abspath(base_directory + r"\app\static\profilepictures")
  182.     UPLOAD_FOLDER = Path.cwd().joinpath("app", "static", "profilepictures")
  183.     # max a file can be is 1 megabyte is that big enough? Todo add warning
  184.     MAX_CONTENT_LENGTH = 1024 * 1024
  185.     CKEDITOR_PKG_TYPE = 'standard'
  186.     # setting up flask mail
  187.     MAIL_USERNAME = os.getenv("EMAIL_USERNAME")
  188.     # app password
  189.     MAIL_PASSWORD = os.getenv("EMAIL_PASSWORD")
  190.     # make secret key work in wtf forms
  191.     WTF_CSRF_ENABLED = True
  192.     # this is the test key for stripe
  193.     stripe.api_key = os.environ['STRIPE_SECRET_KEY']
  194.  
  195.  
  196. class PytestConfig(Config):
  197.     DEBUG = False
  198.     EMAIL_HOST = 'localhost'
  199.     EMAIL_PORT = '0'
  200.     Mail_DEBUG = True  
  201.     # for pytest
  202.     TESTING = True     
  203.     # This is the same value ['TESTING'] =...
  204.     # If you are testing your app and you don't want to send emails make the value True?
  205.     MAIL_SUPRESS_SEND = True  
  206.     # When this is False wtf_forms is disabled. This makes 'POST' request work for pytest routes.
  207.     WTF_CSRF_ENABLED = False
  208.     SQLALCHEMY_TRACK_MODIFICATIONS = True
  209.     SERVER_NAME = 'localhost'
  210.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement