This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ## row_count = 10 | |
| ## offset = 2 | |
| SELECT | |
| column_list | |
| FROM | |
| table1 | |
| ORDER BY column_list | |
| LIMIT row_count OFFSET offset; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| An example flask application showing how to upload a file to S3 | |
| while creating a REST API using Flask-Restful. | |
| Note: This method of uploading files is fine for smaller file sizes, | |
| but uploads should be queued using something like celery for | |
| larger ones. | |
| """ | |
| from cStringIO import StringIO | |
| from boto.s3.connection import S3Connection |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ```from flask_script import Command, Option | |
| class GunicornServer(Command): | |
| description = 'Run the app within Gunicorn' | |
| def __init__(self, host='127.0.0.1', port=8000, workers=4): | |
| self.port = port | |
| self.host = host | |
| self.workers = workers |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from flask_mail import Mail, Message | |
| from flask import Flask | |
| app = Flask(__name__) | |
| app.config.update( | |
| DEBUG=True, | |
| #EMAIL SETTINGS | |
| MAIL_SERVER='smtp.gmail.com', | |
| MAIL_PORT=465, | |
| MAIL_USE_SSL=True, | |
| MAIL_USERNAME = 'your email', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from flask import Flask | |
| from flask_sqlalchemy import SQLAlchemy | |
| from sqlalchemy import Column, Table, ForeignKey | |
| from sqlalchemy.types import Integer, String, DateTime | |
| from sqlalchemy.orm import relationship, backref, session | |
| app = Flask(__name__) | |
| app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = True | |
| app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///user.db' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # pip insstall bcrypt | |
| import bcrypt | |
| from getpass import getpass | |
| #Retrieve the password and encrypt | |
| master_secret_key = getpass() | |
| salt = bcrypt.gensalt() | |
| pw = bcrypt.hashpw(master_secret_key.encode(), salt) | |
| #username and password must to be stored somewhere potentially a keyring API? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def weather_detail(place,unit,hr,m): | |
| mgr=owm.weather_manager() | |
| forecaster = mgr.forecast_at_place(place, '3h') | |
| time=timestamps.tomorrow(hr,m) | |
| weather=forecaster.get_weather_at(time) | |
| t=weather.temperature(unit)['temp'] | |
| st.write(f"## Temperature at {place} for the selected time in {unit} is {t}") | |
| st.title(f"Expected Temperature Changes/Alerts at {hr}:{m}") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def plot_line(days,min_t,max_t): | |
| days=dates.date2num(days) | |
| rcParams['figure.figsize']=6,4 | |
| plt.plot(days,max_t,color='green',linestyle='dashdot',linewidth = 1,marker='o',markerfacecolor='red',markersize=7) | |
| plt.plot(days,min_t,color='orange',linestyle='dashdot',linewidth = 1,marker='o',markerfacecolor='blue',markersize=7) | |
| plt.ylim(min(min_t)-4,max(max_t)+4) | |
| plt.xticks(days) | |
| x_y_axis=plt.gca() | |
| xaxis_format=dates.DateFormatter('%m/%d') | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| st.title("TOMORROW'S WEATHER FORECAST") | |
| place1=st.text_input("NAME OF THE CITY FOR TOMORROW'S FORECAST:", "") | |
| unit1=st.selectbox("Select Temperature Unit for tomorrow's forecast",("celsius","fahrenheit")) | |
| hr1=st.slider("Hour :",min_value=0,max_value=23,step=1) | |
| m1=st.slider("Minute :",min_value=0,max_value=59,step=5) | |
| c=st.button("SUBMIT INFO ") | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| st.title("Weather Forecast") | |
| st.write("## Made by Swarnabha with ❤️") | |
| st.write("### Write the name of a City and select the Temperature Unit and Graph Type :") | |
| place=st.text_input("NAME OF THE CITY :", "") | |
| unit=st.selectbox("Select Temperature Unit",("Celsius","Fahrenheit")) | |
| g_type=st.selectbox("Select Graph Type",("Line Graph","Bar Graph")) | |
| b=st.button("SUBMIT") |
NewerOlder