mamori017.log

歴史的クソブログ

Azure Function AppでHTMLコードを出力する

using System;
using System.Net;
using System.Net.Http.Headers;

public static async Task<HttpResponseMessage> Run(HttpRequestMessage req, TraceWriter log)
{
    // ステータスコード
    HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK);

    // 表示させるHTML
    string html = @"<html><head><meta charset='UTF-8'></head><body><p>Test</p></body></html>";
    response.Content = new StringContent(html);

    // メディアタイプの設定
    response.Content.Headers.ContentType = new MediaTypeHeaderValue("text/html");

    return response;
}