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
import toml | |
from flask import Flask | |
app = Flask('__name__') | |
app.config.from_file('config.toml', toml.load) |
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 | |
import asyncio | |
app = Flask(__name__) | |
@app.get("/data") | |
async def get_data(): | |
await asyncio.sleep(1) | |
return 'Hello' |
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 | |
app = Flask('__name__') | |
@app.get('/hello') | |
@app.post('/hello') | |
def hello(): | |
return 'This is the awesome hello api request' |
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 | |
app = Flask('__name__') | |
@app.route('/hello', methods=['GET', 'POST']) | |
def hello_world(): | |
return 'This is the hello world api request' |
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
CREATE TABLE towns ( | |
id SERIAL UNIQUE NOT NULL, | |
code VARCHAR(10) NOT NULL, -- not unique | |
article TEXT, | |
name TEXT NOT NULL -- not unique | |
); | |
insert into towns ( | |
code, article, name | |
) |
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 celery import Celery | |
import celery_config | |
app = Celery(__name__) | |
app.config_from_object(celery_config) | |
@app.task() | |
def random_task(): | |
pass |
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
broker_url = "{}://{}:{}@{}:{}/{}".format( | |
broker_protocol, | |
broker_username, | |
broker_password, | |
broker_host, | |
broker_port, | |
broker_vhost) | |
worker_send_task_event = False | |
task_ignore_result = True |
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
broker_url = "{}://{}:{}@{}:{}/{}".format( | |
broker_protocol, | |
broker_username, | |
broker_password, | |
broker_host, | |
broker_port, | |
broker_vhost) | |
worker_send_task_event = False | |
task_ignore_result = True |
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
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/1.4.8/socket.io.min.js"></script> | |
<script type="text/javascript" charset="utf-8"> | |
const socket = io('http://localhost:5000') | |
socket.on('connect', () => { | |
console.log("socket connected"); | |
}); | |
</script> |
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, render_template | |
from flask_socketio import SocketIO | |
# Initializing the flask object | |
app = Flask(__name__) | |
# Initializing the flask-websocketio | |
app.config['SECRET_KEY'] = 'secret!' | |
socketio = SocketIO(app) |