CS计算机代考程序代写 c++ cache flex algorithm python chain Java compiler javascript starter-files/test03.in

starter-files/test03.in

starter-files/test05.out.correct

starter-files/List_tests.cpp

starter-files/server.py

starter-files/index.html

starter-files/json.hpp

starter-files/test02.in

starter-files/Makefile

starter-files/test03.out.correct

starter-files/List.h.starter

starter-files/List_public_test.cpp

starter-files/index.css

starter-files/List_compile_check.cpp

starter-files/test01.out.correct

starter-files/test04.out.correct

starter-files/public_error01.in

starter-files/test05.in

starter-files/public_error01.out.correct

starter-files/test01.in

starter-files/test02.out.correct

starter-files/unit_test_framework.h

starter-files/test04.in

POST /api/queue/tail/ HTTP/1.1
Host: localhost
Content-Type: application/json; charset=utf-8
Content-Length: 58

{
“uniqname”: “awdeorio”,
“location”: “Table 3”
}
GET /api/queue/head/ HTTP/1.1
Host: localhost
Content-Type: application/json; charset=utf-8
Content-Length: 0

HTTP/1.1 201 Created
Content-Type: application/json; charset=utf-8
Content-Length: 77

{
“location”: “Table 5”,
“position”: 1,
“uniqname”: “jackgood”
}
HTTP/1.1 204 No Content
Content-Type: application/json; charset=utf-8
Content-Length: 0

starter-files/List_tests.cpp
starter-files/List_tests.cpp// Project UID c1f28c309e55405daf00c565d57ff9ad

#include “List.h”
#include “unit_test_framework.h”

using namespace std;

// Add your test cases here

TEST(test_stub) {
    // Add test code here
    ASSERT_TRUE(true);
}

TEST_MAIN()

“””
Simple HTTP server proxies API requests to a running subprocess, communicating
via stdin and stdout. Requests to non-API routes are served as static files.
“””

import http.server
import subprocess

# Server hostname and port
HOST = “localhost”
PORT = 8000

# Base URL for the API. All API calls must start with this path.
API_ROOT = “/api”

# Executable that handles API calls.
API_EXE = “./api.exe”

class APIRequestHandler(http.server.SimpleHTTPRequestHandler):
“””
Python docs
https://docs.python.org/3.6/library/http.server.html#http.server.SimpleHTTPRequestHandler
https://docs.python.org/3.6/library/http.server.html?highlight=httprequest#http.server.BaseHTTPRequestHandler
“””

# Background process is a class variable (like a static member variable in
# C++ because all instances should share the same subprocess. Otherwise,
# the process’s datastructures would be “reset” with every request.
process = None

def __init__(self, *args, **kwargs):
“””Start the background process that will handle proxied requests.”””
if APIRequestHandler.process is None:
print(“Starting background process {}”.format(API_EXE))
APIRequestHandler.process = subprocess.Popen(
[API_EXE],
bufsize=1,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
)
super().__init__(*args, **kwargs)

def do_GET(self):
“””Handle an HTTP GET request.

GET requests to API_ROOT are proxied to process stdin. GET requests to
all other paths are served as static files.
“””
if self.path.startswith(API_ROOT):
# Proxy to process
self.proxy()
else:
# Serve static file
super().do_GET()

def do_POST(self):
“””Handle an HTTP POST request by proxying to process stdin.”””
self.proxy()

def do_DELETE(self):
“””Handle an HTTP DELETE request by proxying to process stdin.”””
self.proxy()

def proxy(self):
“””Proxy one request to process and proxy one response from process.”””
if not self.path.startswith(API_ROOT):
self.send_error(
http.HTTPStatus.METHOD_NOT_ALLOWED,
“Method not allowed on this path: {}”.format(self.path),
)
return
self.proxy_request()
self.proxy_response()

def proxy_request(self):
“””Proxy a request from HTTP client to process.”””

# Read body of request from HTTP client
content_length = int(self.headers.get(‘content-length’, 0))
host = self.headers.get(‘host’, ‘localhost’)
data = self.rfile.read(content_length).decode(‘utf-8’)

# Remove leading and trailing whitespace from data
data = data.strip()

# Build request string, example:
#
# GET /api/queue/ HTTP/1.1
# Host: localhost
request_str = (
“{method} {path} {version}\n”
“Host: {host}\n”
“Content-Type: application/json; charset=utf-8\n”
“Content-Length: {content_length}\n”
).format(
method=self.command,
path=self.path,
version=self.request_version,
host=host,
content_length=len(data),
)

# Add data, if any
if data:
request_str += “\n”
request_str += data
request_str += “\n”

# Write request to stdin of subprocess
for line in request_str.split(“\n”):
print(“< {}".format(line.strip())) APIRequestHandler.process.stdin.write(bytes(str(request_str), 'utf-8')) APIRequestHandler.process.stdin.flush() def proxy_response(self): """Proxy a response from process to HTTP client.""" # Consume whitespace while APIRequestHandler.process.stdout.peek(1).isspace(): APIRequestHandler.process.stdout.read(1) # Parse HTTP Response response = BytesHTTPResponse(APIRequestHandler.process.stdout) response.begin() data = response.read() # Print response to debug output assert response.version == 11 print("> HTTP/1.1 {} {}”.format(response.status, response.reason))
print(“> Content-Type: {}”.format(response.getheader(“Content-Type”)))
print(“> Content-Length: {}”.format(response.getheader(“Content-Length”)))
print(“>”)
for line in data.decode(“utf8”).split(“\n”):
print(“> {}”.format(line.rstrip()))

# Write response to HTTP client
self.send_response(response.status)
self.send_header(‘Content-type’, ‘application/json’)
self.end_headers()
self.wfile.write(data)

class BytesHTTPResponse(http.client.HTTPResponse):
“””Parse an HTTP response from a byte string.

EXAMPLE:
response = BytesHTTPResponse(b”’HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
Content-Length: 161

{
“queue_head_url”: “http://localhost/queue/head/”,
“queue_list_url”: “http://localhost/queue/”,
“queue_tail_url”: “http://localhost/queue/tail/”
}

”’)
response.begin())
print(response.version)
print(response.status)
print(response.reason)
print(response.getheaders())
print(response.read())
“””

def __init__(self, response_bytes):
“””Create an HTTP Response using a fake underlying socket.”””

class FakeSocket():
“””Adapt stream of bytes interface to Socket interface.”””
def __init__(self, response_bytes):
self._file = response_bytes

def makefile(self, *args, **kwargs):
return self._file

# Create a data stream from a byte string. This data stream will act
# like a socket via the FakeSocket object.
sock = FakeSocket(response_bytes)

# Let super class do the hard work
super().__init__(sock)

def _close_conn(self):
“””Never close the connection (does nothing).”””

def main():
“””Start a server.”””
print(“Starting server on {}:{}”.format(HOST, PORT))
server = http.server.HTTPServer((HOST, PORT), APIRequestHandler)
server.serve_forever()

if __name__ == “__main__”:
main()

EECS 280 Office Hours Queue

EECS
Office Hours

Student View

Log out

Courses

EECS 280

2 – 8pm Eastern OH

Alternate Time Zone OH

Announcements

Please make sure you have a working meeting link. If you
are using Zoom, please monitor your waiting room if enabled! If you are unresponsive when it is
your turn, you will be popped off the queue without being helped.

Queue

The queue is open until 8:00 PM.

Remove Top

Refresh Queue

Sign Up

Uniqname

Description

Meeting Link

Sign Up

×
Bad Request

Your REST API responded with 400 Bad Request!

/*
__ _____ _____ _____
__| | __| | | | JSON for Modern C++
| | |__ | | | | | | version 3.5.0
|_____|_____|_____|_|___| https://github.com/nlohmann/json

Licensed under the MIT License .
SPDX-License-Identifier: MIT
Copyright (c) 2013-2018 Niels Lohmann .

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the “Software”), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/

#ifndef NLOHMANN_JSON_HPP
#define NLOHMANN_JSON_HPP

#define NLOHMANN_JSON_VERSION_MAJOR 3
#define NLOHMANN_JSON_VERSION_MINOR 5
#define NLOHMANN_JSON_VERSION_PATCH 0

#include // all_of, find, for_each
#include // assert
#include // and, not, or
#include // nullptr_t, ptrdiff_t, size_t
#include // hash, less
#include // initializer_list
#include // istream, ostream
#include // random_access_iterator_tag
#include // accumulate
#include // string, stoi, to_string
#include // declval, forward, move, pair, swap

// #include
#ifndef NLOHMANN_JSON_FWD_HPP
#define NLOHMANN_JSON_FWD_HPP

#include // int64_t, uint64_t
#include

// map
#include // allocator
#include // string
#include // vector

/*!
@brief namespace for Niels Lohmann
@see https://github.com/nlohmann
@since version 1.0.0
*/
namespace nlohmann
{
/*!
@brief default JSONSerializer template argument

This serializer ignores the template arguments and uses ADL
([argument-dependent lookup](https://en.cppreference.com/w/cpp/language/adl))
for serialization.
*/
template
struct adl_serializer;

template class ObjectType =
std::map,
template class ArrayType = std::vector,
class StringType = std::string, class BooleanType = bool,
class NumberIntegerType = std::int64_t,
class NumberUnsignedType = std::uint64_t,
class NumberFloatType = double,
template class AllocatorType = std::allocator,
template class JSONSerializer =
adl_serializer>
class basic_json;

/*!
@brief JSON Pointer

A JSON pointer defines a string syntax for identifying a specific value
within a JSON document. It can be used with functions `at` and
`operator[]`. Furthermore, JSON pointers are the base for JSON patches.

@sa [RFC 6901](https://tools.ietf.org/html/rfc6901)

@since version 2.0.0
*/
template
class json_pointer;

/*!
@brief default JSON class

This type is the default specialization of the @ref basic_json class which
uses the standard template types.

@since version 1.0.0
*/
using json = basic_json<>;
} // namespace nlohmann

#endif

// #include

// This file contains all internal macro definitions
// You MUST include macro_unscope.hpp at the end of json.hpp to undef all of them

// exclude unsupported compilers
#if !defined(JSON_SKIP_UNSUPPORTED_COMPILER_CHECK)
#if defined(__clang__)
#if (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__) < 30400 #error "unsupported Clang version - see https://github.com/nlohmann/json#supported-compilers" #endif #elif defined(__GNUC__) && !(defined(__ICC) || defined(__INTEL_COMPILER)) #if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) < 40800 #error "unsupported GCC version - see https://github.com/nlohmann/json#supported-compilers" #endif #endif #endif // disable float-equal warnings on GCC/clang #if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wfloat-equal" #endif // disable documentation warnings on clang #if defined(__clang__) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wdocumentation" #endif // allow for portable deprecation warnings #if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__) #define JSON_DEPRECATED __attribute__((deprecated)) #elif defined(_MSC_VER) #define JSON_DEPRECATED __declspec(deprecated) #else #define JSON_DEPRECATED #endif // EECS280 modification #define JSON_NODISCARD // ORIGINAL // allow for portable nodiscard warnings // #if defined(__has_cpp_attribute) // #if __has_cpp_attribute(nodiscard) // #define JSON_NODISCARD [[nodiscard]] // #elif __has_cpp_attribute(gnu::warn_unused_result) // #define JSON_NODISCARD [[gnu::warn_unused_result]] // #else // #define JSON_NODISCARD // #endif // #else // #define JSON_NODISCARD // #endif // allow to disable exceptions #if (defined(__cpp_exceptions) || defined(__EXCEPTIONS) || defined(_CPPUNWIND)) && !defined(JSON_NOEXCEPTION) #define JSON_THROW(exception) throw exception #define JSON_TRY try #define JSON_CATCH(exception) catch(exception) #define JSON_INTERNAL_CATCH(exception) catch(exception) #else #define JSON_THROW(exception) std::abort() #define JSON_TRY if(true) #define JSON_CATCH(exception) if(false) #define JSON_INTERNAL_CATCH(exception) if(false) #endif // override exception macros #if defined(JSON_THROW_USER) #undef JSON_THROW #define JSON_THROW JSON_THROW_USER #endif #if defined(JSON_TRY_USER) #undef JSON_TRY #define JSON_TRY JSON_TRY_USER #endif #if defined(JSON_CATCH_USER) #undef JSON_CATCH #define JSON_CATCH JSON_CATCH_USER #undef JSON_INTERNAL_CATCH #define JSON_INTERNAL_CATCH JSON_CATCH_USER #endif #if defined(JSON_INTERNAL_CATCH_USER) #undef JSON_INTERNAL_CATCH #define JSON_INTERNAL_CATCH JSON_INTERNAL_CATCH_USER #endif // manual branch prediction #if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__) #define JSON_LIKELY(x) __builtin_expect(!!(x), 1) #define JSON_UNLIKELY(x) __builtin_expect(!!(x), 0) #else #define JSON_LIKELY(x) x #define JSON_UNLIKELY(x) x #endif // C++ language standard detection #if (defined(__cplusplus) && __cplusplus >= 201703L) || (defined(_HAS_CXX17) && _HAS_CXX17 == 1) // fix for issue #464
#define JSON_HAS_CPP_17
#define JSON_HAS_CPP_14
#elif (defined(__cplusplus) && __cplusplus >= 201402L) || (defined(_HAS_CXX14) && _HAS_CXX14 == 1)
#define JSON_HAS_CPP_14
#endif

/*!
@brief macro to briefly define a mapping between an enum and JSON
@def NLOHMANN_JSON_SERIALIZE_ENUM
@since version 3.4.0
*/
#define NLOHMANN_JSON_SERIALIZE_ENUM(ENUM_TYPE, …) \
template \
inline void to_json(BasicJsonType& j, const ENUM_TYPE& e) \
{ \
static_assert(std::is_enum::value, #ENUM_TYPE ” must be an enum!”); \
static const std::pair m[] = __VA_ARGS__; \
auto it = std::find_if(std::begin(m), std::end(m), \
[e](const std::pair& ej_pair) -> bool \
{ \
return ej_pair.first == e; \
}); \
j = ((it != std::end(m)) ? it : std::begin(m))->second; \
} \
template \
inline void from_json(const BasicJsonType& j, ENUM_TYPE& e) \
{ \
static_assert(std::is_enum::value, #ENUM_TYPE ” must be an enum!”); \
static const std::pair m[] = __VA_ARGS__; \
auto it = std::find_if(std::begin(m), std::end(m), \
[j](const std::pair& ej_pair) -> bool \
{ \
return ej_pair.second == j; \
}); \
e = ((it != std::end(m)) ? it : std::begin(m))->first; \
}

// Ugly macros to avoid uglier copy-paste when specializing basic_json. They
// may be removed in the future once the class is split.

#define NLOHMANN_BASIC_JSON_TPL_DECLARATION \
template class ObjectType, \
template class ArrayType, \
class StringType, class BooleanType, class NumberIntegerType, \
class NumberUnsignedType, class NumberFloatType, \
template class AllocatorType, \
template class JSONSerializer>

#define NLOHMANN_BASIC_JSON_TPL \
basic_json

// #include

#include // not
#include // size_t
#include // conditional, enable_if, false_type, integral_constant, is_constructible, is_integral, is_same, remove_cv, remove_reference, true_type

namespace nlohmann
{
namespace detail
{
// alias templates to reduce boilerplate
template
using enable_if_t = typename std::enable_if::type;

template
using uncvref_t = typename std::remove_cv::type>::type;

// implementation of C++14 index_sequence and affiliates
// source: https://stackoverflow.com/a/32223343
template
struct index_sequence
{
using type = index_sequence;
using value_type = std::size_t;
static constexpr std::size_t size() noexcept
{
return sizeof…(Ints);
}
};

template
struct merge_and_renumber;

template
struct merge_and_renumber, index_sequence>
: index_sequence < I1..., (sizeof...(I1) + I2)... > {};

template
struct make_index_sequence
: merge_and_renumber < typename make_index_sequence < N / 2 >::type,
typename make_index_sequence < N - N / 2 >::type > {};

template<> struct make_index_sequence<0> : index_sequence<> {};
template<> struct make_index_sequence<1> : index_sequence<0> {};

template
using index_sequence_for = make_index_sequence;

// dispatch utility (taken from ranges-v3)
template struct priority_tag : priority_tag < N - 1 > {};
template<> struct priority_tag<0> {};

// taken from ranges-v3
template
struct static_const
{
static constexpr T value{};
};

template
constexpr T static_const::value;
} // namespace detail
} // namespace nlohmann

// #include

#include // not
#include // numeric_limits
#include // false_type, is_constructible, is_integral, is_same, true_type
#include // declval

// #include

// #include

#include // random_access_iterator_tag

// #include

namespace nlohmann
{
namespace detail
{
template struct make_void
{
using type = void;
};
template using void_t = typename make_void::type;
} // namespace detail
} // namespace nlohmann

// #include

namespace nlohmann
{
namespace detail
{
template
struct iterator_types {};

template
struct iterator_types < It, void_t>
{
using difference_type = typename It::difference_type;
using value_type = typename It::value_type;
using pointer = typename It::pointer;
using reference = typename It::reference;
using iterator_category = typename It::iterator_category;
};

// This is required as some compilers implement std::iterator_traits in a way that
// doesn’t work with SFINAE. See https://github.com/nlohmann/json/issues/1341.
template
struct iterator_traits
{
};

template
struct iterator_traits < T, enable_if_t < !std::is_pointer::value >>
: iterator_types
{
};

template
struct iterator_traits::value>>
{
using iterator_category = std::random_access_iterator_tag;
using value_type = T;
using difference_type = ptrdiff_t;
using pointer = T*;
using reference = T&;
};
}
}

// #include

// #include

#include

// #include

// http://en.cppreference.com/w/cpp/experimental/is_detected
namespace nlohmann
{
namespace detail
{
struct nonesuch
{
nonesuch() = delete;
~nonesuch() = delete;
nonesuch(nonesuch const&) = delete;
void operator=(nonesuch const&) = delete;
};

template class Op,
class… Args>
struct detector
{
using value_t = std::false_type;
using type = Default;
};

template class Op, class… Args>
struct detector>, Op, Args…>
{
using value_t = std::true_type;
using type = Op;
};

template