Giter VIP home page Giter VIP logo

perfectserverdemo's Introduction

Perfect Server Demo

Project Requirements

In order to run this server, you'll need Swift 3 installed on your machine. If you're using a Mac, you already have everything you need. Otherwise follow Apple's instructions to install Swift before continuing.

You'll also need the latest Xcode installed. This is not a hard-fast requirement, but it does allow for easier debugging.

Setup

Once you have Swift installed, run the following commands in a terminal

$ cd /path/to/where/you/cloned/this/repo
$ swift package generate-xcodeproj

This will download Perfect and all its necessary dependencies to run the application. Once you've installed all the necessary dependencies, open the Xcode project file generated by the Swift Package Manager. You'll need to edit the scheme and set the working directory for the project. You can do this by selecting the terminal scheme and clicking on Edit Scheme -> Run -> Options -> Use custom working directory: and clicking on the folder icon to select the root of this project (where the project file is).

Finally, select the terminal scheme and run the server. You should see [INFO] Starting HTTP server on 0.0.0.0:8080 printed to the console if everything is setup correctly.

API Spec v1

There are 2 existing endpoints:

POST v1/key

Given the correct username, returns the "authorization key" to be used on subsequent requests.

Parameters

Parameter Expected Value
username the user you wish to have logged in

Example Request

POST http://localhost:8080/v1/key

{
   "username": "matt"
}

Example Response

{
"accessKey": "FB919310-6D87-4B49-B37F-222E1693C754"
}

GET v1/image

Returns an image, as Data. This endpoint does require the Authorization header -- use the token returned by the v1/key endpoint

Parameters

None.

Example Request

GET http://localhost:8080/v1/image

Example Response

logo

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.