public static void Main(string[] args) { try { config = IMainFunction.FromJsonFile <Config>("config.json"); } catch { config = new Config() { _port = "http://localhost:5000" }; } IMainFunction.ToJsonFile("config.json", config); ms = new MessagesClass(); //обработка сообщений Sessions = new SessionsClass(); // хранение токенов логинов и паролей //Sessions.addValera(); Sessions.LoadFromFile(); ms.LoadFromFile(); // Console.WriteLine(Sessions.list_tokens.Count); CreateHostBuilder(args).Build().Run(); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { try { config = IMainFunction.FromJsonFile <Config>("config.json"); } catch { config = new Config() { _port = "http://localhost:5000" }; } services.AddControllers(); services.AddCors(options => { options.AddPolicy("CorsApi", builder => builder.WithOrigins(config._port) .AllowAnyHeader() .AllowAnyMethod()); }); }