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 'package:flutter/material.dart'; | |
void main() => runApp(MyApp()); | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(context) => | |
MaterialApp( | |
home: MyHomePage() | |
); |
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 'package:flutter/material.dart'; | |
void main() => runApp(MyApp()); | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(context) => | |
MaterialApp( | |
home: MyHomePage() | |
); |
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
class AnnouncementPage extends StatefulWidget { | |
AnnouncementPage(this.nickname); | |
final String nickname; | |
@override | |
AnnouncementPageState createState() => AnnouncementPageState(); | |
} | |
class AnnouncementPageState extends State<AnnouncementPage> { |
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 'package:flutter/material.dart'; | |
import 'package:web_socket_channel/web_socket_channel.dart'; | |
// substitute your server's IP and port | |
const YOUR_SERVER_IP = 'SERVER_IP'; | |
const YOUR_SERVER_PORT = 'SERVER_PORT': | |
const URL = 'ws://$YOUR_SERVER_IP:$YOUR_SERVER_PORT'; | |
void main() => runApp(MyApp()); |
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
for(var cl of server.clients) { | |
cl.send(message); | |
} |
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 'package:flutter/material.dart'; | |
void main() => runApp(MyApp()); | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(context) => | |
MaterialApp( | |
home: Scaffold( | |
appBar: AppBar(title: Text("Example app")), |
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
var sqlite = require('sqlite3'); | |
var db = new sqlite.Database("users.sqlite3"); | |
db.run(`CREATE TABLE users( | |
id INTEGER PRIMARY KEY, | |
username TEXT NOT NULL, | |
password TEXT NOT NULL | |
)`); |
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
class HomePage extends StatelessWidget { | |
HomePage(this.jwt, this.payload); | |
factory HomePage.fromBase64(String jwt) => | |
HomePage( | |
jwt, | |
json.decode( | |
ascii.decode( | |
base64.decode(base64.normalize(jwt.split(".")[1])) | |
) |
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
app.get('/data', function(req, res) { | |
var str = req.get('Authorization'); | |
try { | |
jwt.verify(str, KEY, {algorithm: 'HS256'}); | |
res.send("Very Secret Data"); | |
} catch { | |
res.status(401); | |
res.send("Bad Token"); | |
} |
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
var express = require('express') | |
var multer = require('multer') | |
var fs = require('fs'); | |
var upload = multer({ dest: 'uploads/' }) | |
var app = express() | |
app.post('/upload', upload.single("picture"), function (req,res) { | |
console.log("Received file" + req.file.originalname); | |
var src = fs.createReadStream(req.file.path); |