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
procedure TForm1.OnPost(Sender: TObject); | |
begin | |
{ Translate text test } | |
httpClient := TFPHTTPClient.Create(nil); | |
httpClient.RequestBody := TRawByteStringStream.Create(Memo1.Text); | |
ResponseRest := TStringStream.Create(''); | |
try | |
try | |
httpClient.Post('<REPLACE WITH YOUR URL TO REST POST API>', ResponseRest); | |
Memo2.Lines.Add('Response Code is ' + inttostr(httpClient.ResponseStatusCode)); |
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 extension IF NOT EXISTS "uuid-ossp"; | |
-- Table: public.books | |
CREATE TABLE IF NOT EXISTS public.books | |
( | |
bookid uuid NOT NULL DEFAULT uuid_generate_v4(), | |
title character varying COLLATE pg_catalog."default", | |
book_info jsonb, | |
CONSTRAINT books_pkey PRIMARY KEY (bookid) | |
) |
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
class BooksHandler(BaseHandler): | |
""" | |
GET handler for fetching all books from the database | |
""" | |
@gen.coroutine | |
def get(self): | |
self.set_status(200) | |
self.write({'message': 'All books sorted by title', 'books': []}) | |
self.finish() |
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
class BookHandler(BaseHandler): | |
def initialize(self): | |
database_url = os.environ['BOOKS_DB_CONN'] | |
self.session = queries.TornadoSession(uri=database_url) | |
""" | |
GET handler for fetching numbers from database | |
""" | |
@gen.coroutine |
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 json | |
import ast | |
import datetime | |
import tornado.httpserver | |
import tornado.options | |
import tornado.ioloop | |
import tornado.web | |
import tornado.wsgi | |
from passlib.hash import pbkdf2_sha256 |
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
procedure THeaderFooterwithNavigation.FormCreate(Sender: TObject); | |
begin | |
{ This defines the default active tab at runtime } | |
TabControl1.First(TTabTransition.None); | |
{ TODO: Navigate to URL on load } | |
end; | |
procedure THeaderFooterwithNavigation.OnNavCompleted(Sender: TObject; | |
var Params: TTMSFNCCustomWebBrowserNavigateCompleteParams); | |
begin |
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
procedure THeaderFooterwithNavigation.FormCreate(Sender: TObject); | |
var | |
url: string; | |
begin | |
{ This defines the default active tab at runtime } | |
TabControl1.First(TTabTransition.None); | |
{ TODO: Navigate to URL on load } | |
url := 'https://www.fitbit.com/oauth2/authorize?response_type=code' + | |
'&client_id=<YOUR_CLIENT_ID_GOES_HERE>' + | |
'&redirect_uri=http%3A%2F%2Flocalhost' + |
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 asyncio | |
# ... | |
# Added async to main | |
async def main(): | |
print("starting tornado server..........") | |
app = make_app() | |
app.listen(tornado.options.options.port) | |
await asyncio.Event().wait() |
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
uses | |
System.DateUtils; | |
procedure FormatDateToString(): string; | |
var | |
CurrentDate: TDateTime; | |
FmtStngs: TFormatSettings; | |
begin | |
{ As a bonus using IncDay will get you any day from current date, such as yesterday would be IncDay(Now, -1) } | |
CurrentDate := IncDay(Now, 0); |