This file contains 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 os | |
import requests | |
from flask import Flask,jsonify,render_template,request | |
from flask_socketio import SocketIO,emit,join_room,leave_room,send | |
from werkzeug import secure_filename | |
This file contains 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
document.addEventListener('DOMContentLoaded',()=>{ | |
var socket = io.connect(location.protocol + '//' + document.domain + ':' + location.port); | |
socket.on('connect',()=>{ | |
document.querySelector('#submit-user').onclick= ()=>{ | |
const user = document.querySelector('#user').value; | |
socket.emit('submit user',{'user':user}); | |
return false; |
This file contains 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
//code running on user machine | |
document.addEventListener('DOMContentLoaded',()=>{ | |
var socket = io.connect(location.protocol + '//' + document.domain + ':' + location.port); | |
socket.on('connect',()=>{ | |
document.querySelector('#submit').onclick= ()=>{ | |
const user = document.querySelector('#user').value; | |
const room = document.querySelector('#room').value; | |
socket.emit('join',{'user':user,'room':room}); |
This file contains 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
{% extends "layout.html" %} | |
{% block heading %}Book list{% endblock %} | |
{% block body %} | |
<h1>Book details</h1> | |
<table class="table table-striped"> | |
<thead> | |
<th scope="col">Isbn</th> |
This file contains 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
{% extends "layout.html" %} | |
{% block heading %}found {% endblock %} | |
{% block body %} | |
This file contains 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 os | |
from flask import Flask,render_template,request,session | |
from flask_session import Session | |
from werkzeug.security import generate_password_hash, check_password_hash | |
from sqlalchemy import create_engine | |
from sqlalchemy.orm import scoped_session, sessionmaker | |
engine = create_engine(os.getenv("DATABASE_URL")) |
This file contains 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 BOOKS (id SERIAL, | |
isbn VARCHAR PRIMARY KEY, | |
title VARCHAR NOT NULL, | |
author VARCHAR NOT NULL, | |
year VARCHAR NOT NULL | |
); |
This file contains 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>{% block title %}{% endblock %}</title> | |
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" integrity="sha384-WskhaSGFgHYWDcbwN70/dfYBj47jz9qbsMId/iRN3ewGhXQFZCSftd1LZCfmhktB" crossorigin="anonymous"> | |
</head> | |
<body> | |
<div class="jumbotron"> | |
<h1 class="display-3">Welcome to Bookkeepers!</h1> | |
This file contains 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 os | |
from sqlalchemy import create_engine | |
from sqlalchemy.orm import scoped_session, sessionmaker | |
engine = create_engine(os.getenv("DATABASE_URL")) | |
db = scoped_session(sessionmaker(bind=engine)) | |
def main(): |
This file contains 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 registered_user ( | |
id SERIAL PRIMARY KEY, | |
userid VARCHAR UNIQUE NOT NULL, | |
hash_password VARCHAR NOT NULL | |
); | |
NewerOlder